Yes, they hack into the game's code and change it. It's a fairly common practice among ROM pirates since all the tools and how-tos are 100% free.