Right before the Elements struck, the Nightmare unleashed a spell out of desperation. A substitution spell. Otherwise known as the correct use of Kawarimi.
Nightmare Moon banished Celestia, only to be defeated by Ahuizotl. Ponykind were made the scapegoats to blame for her scourge. 1000 years they pray for a saviour to deliver them. Anypony will do. Enter the last hope, a pizza delivery dude.