The CPU is constantly reading/writing to/from the cartridge addresses. If someone knows the address of things like number of lives, or even something else tied to values like health then you can easily intercept and modify those values. That's essentially what the game genie was doing...