Pikachu magically summons balloons from out of nowhere with its powers, then flies in the air with them :3
You can also see it in Pokémon Yellow:
There have been some event pikachu with fly, too.
As for why it can learn fly, Game Freak probably thought it was cute and that it would be something to get peoples attention.
This is most likely why the surfing pikachu exists as well