The anime follows a different set of rules than the games. This has been evidenced when Ash's Pikachu defeated Ground types like Onix with Electric moves on several occasions. Levels also don't seem to exist, not like they do in the games. Pokemon in the anime simply learn moves they can't in the games because the developers wanted them to, or they decided it would make sense for that Pokemon to know that move. Ultimately, however, only the creators of the anime can give you a definite answer.
Hope I helped!