More important question: How in the name of Arceus do people even figure all of this shit out? XD
The game's been out for over 20 years now. Bored tech-savvy nerds have had lots of time to dissect it. XD
Also, ZZAZZ Glitch, the guy I keep getting most of these videos from, uses a program that lets him see the entire code of the game and which values are being changed in real-time. So with that in mind, you can see how one can say "Ah, yes, viewing the sprite of this glitch pokemon corrupts
this other part of the game's code... for... some reason!" And then, by making sense of the patterns that emerge in these changes, what areas of the code are being affected and under what conditions, and what those changes will cause the game to
do when the corrupted code is read -- you can see how people have been able to figure out some pretty intricate stuff.
Honestly I'm more surprised at the things that
haven't been figured out yet. Like, after you successfully capture 'M, the battle continues as normal, as if you didn't catch it at all. And if you
then catch the "phantom" 'M that you were left fighting after the first capture, the game will treat it as a Ditto.
You will have captured 'M,
and you will have captured a mostly normal Ditto, with the only weird thing about it being that it still has 'M's level (which is often 0). Its attacks, stats, and all its other behavior are all perfectly normal.
No one knows why this happens.
People have dug deep enough into this game to figure out how to re-program it to do damn near anything we want. We still don't know why capturing 'M results in the battle continuing with a "phantom" 'M that the game treats as a Ditto after capture.