Sorry if this has been asked, but I looked all over and couldn't find it. I was just wandering around on Route 14 and Meloetta appeared. I caught it with my Master Ball. But I never knew it would appear like that. I haven't used any codes. I wouldn't even know how.
Meloetta doe not appear randomly in the wild; it was only given out through an event that has long since passed. You must have used codes in the past, and if you didn't, the person who had the game before you must have.