Oh, I remember this glitch all too well. I've actually experienced with it probably too much for my own good, even to the point of fighting my rival the first time with a Crobat, and fighting Morty with an Umbreon that could use Shadow Ball.
I think the reason the pokemon doesn't show up in the pokedex is that since you turn the game off without saving, the game doesn't know that you even obtained the pokemon. I still don't know how the pokemon ends up in the PC though, but that must be the data registered first whenever you save the game.
(Also, if you take someone out of the PC that was there before, it will disappear, I think)