Missingno works this way too, but a bit differently.
EDIT: Thought you'd like this... sorry bought quality
DP Missingno
Not mine btw.
If you're bored and care to read how this works:
What happened was Nintendo ran out of room making the GB carts, since they're so small for data. Some Pokemon data got mixed in with some pixels, trainers, and other numbers this way. When you encounter this trainer, the game takes that data into account for your last encounter (The game receives and keeps each encounter data every time you enter a battle or an area that contains wild Pokemon). The game sets up to receive data for this battle, but doesn't finish, thus causing the glitch.
Usually, what you encounter is based off a data record, but apparently running into this trainer blanks out this data. The game gets confused and takes the first possible number it can, and apparently that's the Special Stat of the last Pokemon you fought. The last Pokemon this trainer fought was a shellder, and I guess it had the Special stat of 21. So when you return to this route, the game takes the data for here, resumes what it can, and ends up loading up that number, 21. Mew's data number is 21, to get other things, you basically gotta run into a Ditto, have a Pokemon in the first slot with the special stat "code" you need, let the Ditto transform, and kill it. Then return to nugget bridge and y'know the rest.
Missingno works the same way. The game takes the time to change your player's name to Old Man from what it originally was, in Viridian City. As I've said before, Nintendo tried to find ways to save room, and this data (The name OLD MAN) was saved in the Pokemon data.
The side of Cinnebar (Spelling prolly wrong :/) was never wired to encounter any specific Pokemon, but it is still a spot you can run into Pokemon in. The last known data the game had, was, of course, OLD MAN, which is bound to cause some problems right? The game takes the data from OLD MAN, and it gets pretty glitchy. Apparently it's just a random assortment of data, if you look closely Missingno's type is "Bird", and there is no Bird Pokemon (But there is Flying of course). And then there's other Pixels Nintendo prolly saved in here since they ran out of room.
That Mew method is the only way to end up with Missingno in Yellow, it's there (Game still needs room), but the side of Cinnebar was patched up. There's similar glitches in ALL Pokemon games, since there's times when the game needs something to grab for a certein event, and there's glitches to force these numbers in.