It depends on how the game (or the program, if not running a game) is programmed. It does not depend on the system, but on where the memory where program is executed is physically located. If a program is loaded in RAM that stays inside the system and uses RAM which is inside the system, it won't freeze when removing the cartridge. On the other hand, if the program is executed directly from ROM or RAM that is inside the cartridge, it will freeze when removing the cartridge, as the CPU will fetch instructions from a non-existing memory. This is applicable to both NES and GBA.
In the vast majority of cases there's no reason not to execute code from ROM directly, as code runs at the same speed constantly. There's no point copying code to RAM if there's no need to. It is however perfectly possible to load a program in the system's internal 2 KiB of RAM and execute it, if the ROM is not used anymore it is possible to make a program that does not crash when removing the cartridge(*). This technique is called hotswapping and is actually used, for example to dump games or to test expansion audio chips from genuine Famicom cartridges without destroying them.
Game Boy Advance
The system has more types of memory: In addition to cartridge ROM, there's on-system WRAM and on-system IRAM. Each type of memory is a trade-off between size and speed. Speed is indicated as (x / y), where x is the # of cycles per instruction in 16-bit Thumb mode, and y the # of cycles per instructions in 32-bit ARM mode. According to GBATEK, when it comes to executing code
- Cartridge ROM is the slowest (8 / 5 cycles) but also the largest
- WRAM is faster (6 / 3 cycles) but limited to 256 KiB
- IWRAM is fastest (1 cycle), but smallest, being limited to 32 KiB
- VRAM can also be used to execute code (2 / 1 cycle). It is however small, and using it removes space normally used for display, so using this limits graphic possibilities
- Cartridge RAM (8 cycles) could be used but there's really no point as it is normally dedicated to save games
Whether code is executed from WRAM, IWRAM or VRAM, it will not crash when removing the cartridge. When it is executing from cartridge ROM (or from cartridge RAM - something almost completely useless) it will crash as soon as the cartridge is removed.
In most cases, games runs the majority of the code directly from ROM as RAM is limited, and does so in 16-bit Thumb mode. Critical bottlenecks are loaded in IWRAM and executed in ARM mode. This is however not an absolute, any game can do whatever it likes to.
You can extend this concept to any other system using cartridges.
(*) However, as the cartridge is also used as a source for pattern assets, the graphics will be completely screwed up, but technically the program does not freeze.