I've got an explanation that (hopefully) gets around this "downfall" timeline problem.
I'll go from the top, and try to keep it within the character limit.
—
Ocarina of Time's story begins with Link orphaned in the Kokiri Woods as a baby.
He grows up a bit, is sent by the Deku Tree to meet Princess Zelda, who explains her premonitions involving Link and Gannondorf, and her plan to get herself and Link into the Sacred Realm (to claim the Triforce) before Gannondorf can.
Gannondorf figures out their plan, chases Zelda away from Hyrule Castle, and then allows Link to claim the Master Sword and get himself locked in a bullshit magical stasis field, letting Gannondorf enter the Sacred Realm unopposed.
Oh, and we'll call this timeline [A].
When Link awakens seven years later, hears about the Sages from Sheik, and sets out to awaken them, this is still on timeline [A]; no "time-travel" has taken place, apart from Link's perspective where he was kept asleep for years.
BUT
At least once in the story, Link has to return to the Master Sword pedestal, where (after a vague explanation from Sheik) it turns out that Link can use the pedestal to "return" to the moment in time before he drew the Master Sword. His memories (and even his equipment) are sent back to this moment, at which point the timeline splits because the past has been altered.
Up until the end of the story, there's now two timelines linked together; timeline [B] is essentially the same as [A], but altered by the knowledge and the items Link previously gained.
For simplicity's sake, assume that any future loops just overwrite [A] and [B] repeatedly ([A] is the timeline that Link's in when he drops the sword into the pedestal, and the new [B] timeline always 'begins' in an altered past, just before Link would've drawn the Master Sword), since there's nothing you can do in-game to break this loop anyway (ie. prevent Gannondorf from entering the Sacred Realm).
SO
LINK FUCKED AROUND WITH THE 'PAST' AT LEAST ONCE TO COMPLETE HIS QUEST
BUT IF HE'D BEEN ALLOWED TO USE THE PEDESTAL ONE MORE TIME AFTER DEFEATING GANON
THEN ONE TIMELINE WOULD STILL BE SAVED, AND HE'D HAVE A CHANCE OF SAVING THE OTHER ONE
BUT NO
ZELDA JUST HAD TO FUCK EVERYTHING UP EVEN MORE
JUST BECAUSE SHE WAS TRYING TO DO SOMETHING THOUGHTFUL FOR LINK
Hoping to let Link live out his childhood peacefully, Zelda takes the Ocarina of Time from him, and uses her power as a Sage to manipulate time and send Link to an earlier point in the 'past' than [B] was, effectively creating timeline [C].
Due to Zelda's magical fuckery, the Link that existed in timeline [C] is moved to the Master Sword pedestal, and he now has memories from timelines [A] and [B]. He's at a point in time before his first meeting with Princess Zelda, so when he does go to meet her, he changes [C]'s fate by ensuring Gannondorf is investigated and put on trial before he can put his plans into motion.
(Side Note: Though he has memories from the other timelines, it's not clear what items Link retained; King Daphnes in Wind Waker implies that the Triforce of Courage left Link's body and remained in [B] while Zelda was sending him to [C]).
—
TL;DR, At the very end of Ocarina of Time, here's how the timelines stand:
[A] - Link sent his memories and equipment to his 'past self', but his present-day self then failed to defeat Gannondorf. Leads to the "Imprisoning War" and LoZ: ALttP.
[B] - Gannondorf is sealed in the Sacred Realm, but Zelda inadvertently removes Link from this timeline. Leads to the "Flooding of Hyrule" and LoZ: WW.
[C] - Link gets Gannondorf 'executed', and the Sacred Realm remains sealed. Leads into the games LoZ: MM and LoZ: TP.