Because they both show a different event.Ocarina of Time ended with the Seven Sages trapping Ganondorf in the Dark Realm. The Sages were friends of Link, who he helped reawaken to assume their role as sage. In Twilight Princess, which takes place a century later, the Sages are ghostly apparitions who try to execute Ganondorf, and after failing so, subsequently imprison him in the Twilight Realm. However, these are technically two seperate Ganondorfs.The reason is that Ocarina of Time splits the entire chronology into three timelines: the Child Era, the Adult Era and the Defeat Era. In the Adult Era, Ganondorf was defeated by Link, and locked away into the Sacred Realm with the aid of Link's Sage friends. This timeline is followed by The Wind Waker (where Ganondorf escapes from the Realm). In the Child Era, the story happened in a different way, and a different group of Sages was called upon to banish Ganondorf at the Arbiter's Grounds. These events were not shown in Ocarina of Time as they happened after the events of that game, and Link did not take part in this since he was only a child then. It should also be noted that the Link from Twilight Princess is another reincarnation of the Hero, and thereby a different person than the Link from Ocarina of Time, since there is a century between them. However, the Ganondorfs from both games are (more or less) the same, as Ganondorf's trapped spirit from Ocarina of Time is released in Twilight Princess.