<major pedantry>
Technically it should be Invulnerability rather than Invincibility as the latter means "cannot be defeated" whereas the former means "cannot be harmed at all".
</major pedantry>
Commenting on the Super Mario 64 example: if I remember right, as the example implies, the game did have Mercy Invincibility normally but during the lava levels you had a problem. It's not that you didn't have it when you hit lava, if I recall correctly, you did have it but when you got flung into the air and landed and flinched, that would be all of your grace period. However, if you ended up being flung onto more lava, that means you didn't have the chance to get off and you had to hope that you'd be flung far enough to get back to land before you lost all your health.
For the Undertale example, there are also items sold at a shop that extend your mercy invincibility when equipped (the Torn Notebook and the Cloudy Glasses).