If Gravity wasn't in use and you weren't holding an item that affects levitating Pokémon, then the only explanation is that you used Roost on that turn.
If a Flying type Pokémon uses Roost, their Flying typing is taken away for that turn, making them vulnerable to Ground attacks and other moves that would usually not affect them.
I find this highly likely, as you probably predicted the switch and used Roost.
Another possibility is that you were hit by Smack Down, and somehow survived.
Source: Experience