The Untouchable/Invinciblity state occurs either when your character aquires an ingame powerup that enables the character to pass through enemies/hazards unscaved (usually with powerups it also kills the enemies) or when your character is hit and is giving a short window of immunity from following attacks. There are also games that give you no window of immunity after being hit or your character dies in one hit. Below is an explanation on obtaining Untouchable/Invincibility codes for most games.
Disabled Death Routine:
A flag is usually set (to a higher or lower value) when your character dies. You can usually watch for these flags in the hex editor or even search for values 1 and 0 or in reverse respectively when your character is alive or dead. In games where 1 hit kills you there is most likely no animation for getting hit other than death. Finding this flag and setting it to always reflect the characters living value will usually trigger the character to be untouchable/Invincible. In addition you can set a breakpoint for read on the flag and modify the call to the death routine to disable it if just setting the flag to the Living Value doesnt work.
Disabled Sprite Colision:
The easiest way I've found to hack these types of codes is by setting a break for write on the health address. Once an enemy touches you it should break, next you can either check above the break for a branch that jumps over your current position in ASM or you can step out of the routine and check above where the routine was called for a branch that jumps over the call position. Using this method may only work for particular types of enemies/hazards and may require multiple codes to achive a complete untouchable state.
Built In Invincibility:
Some games give power ups for invinciblity or have a routine that when hit you are given a short window of invincibility. These states are usually set with a flag in memory set to a higher or lower value than its normal state. You can usually watch for these flags in the hex editor or even search for values 1 and 0 or in reverse respectively when your character is invincible by use of a power up or directly after they are hit (usually a flash occures when being hit). Finding this flag and setting it to always reflect the characters Invincibility value will usually trigger the character to be untouchable/Invincible (Usually Flashing).