Turns out Twilight's parents were pushed into the past by weeping angels when her mom was still pregnant. When Twilight from two days in the future saw what happened to her parents, she let herself get attacked by the angels in the hope of going wherever her strangely pregnant mother just disappeared. She found herself in the times before Luna was even banished. The TARDIS shows up and whooves frantically tries to deliver Twilight back home. Whooves doesn't have the time to explain everything about the angels

, giving only little hurried titbits of information. Then, the old blue girl winds up in the middle of a Forest, where Pinkie Pie has just offloaded a certain swarm of parasprites from the show's recent past.
The TARDIS has to disappear because whooves won't let it get eaten by the parasprites. Twilight mistakenly thinks the best thing to do is to not let her mother get touched by the angels, obviously not having made sense of anything whooves said. This unfortunately succeeds. If Twilight's mom wasn't pushed to the past then she would have been born later than this day. It alters the timeline such that Twilight never became Celestia's student, and nopony else was able to effectively wield the element of magic. It's then she realises that it was her inside her mother's womb. But there's more pressing issues as Night Mare Moon rules Equestria in eternal darkness, and Fluttershy weeps for her dying petunias, hoping they may see sunlight soon.
Now Twilight has to make friends with everypony all over again, just so she can stop night mare moon for long enough to fix this whole damn mess... ..somehow.
Though Night Mare Moon was easily defeated again, they can't seem to figure the rest of it out, and Twilight now seems set on just staying in this horrendous alternate reality. They all board the train to go to Appleloosa, just like Twilight remembers, having to go through that same old dialogue about trees again... when suddenly a future Rainbow Dash emerges from the engine, saying "The doc and I, we got this covered." The train hovers off the tracks, shooting into the air at roughly 88 miles per hour, before disappearing in a flash.
You're probably asking "at what point in this story does Twilight get a warning from her future self?"
Right about here. This is the backstory to the episode.