Let's begin my first establishing the timeline, as we know it:
- Master Xehanort, way back in Birth by Sleep, tried to create the keyblade by separating Ventus and his darkness and recombining them. Though he failed, he gained Terra's body as a new vessel to replace his old, frail body.
- In the original Kingdom Hearts, that new Xehanort (now Ansem) became a heartless and tried to use the 7 princesses of heart to open the door to Kingdom Hearts. He failed, and was destroyed.
- In Kingdom Hearts II, the nobody that Xehanort left behind formed an Organization with 12 other nobodies. This group has 2 objectives: To both gather enough hearts to create Kingdom Hearts, and to gather 13 vessels of darkness as a contingency. He also failed, and got destroyed.
- With both the heartless and nobody defeated, Xehanort was restored, and was free to take up the backup plans set up by his heartless and nobody. Gathering his past and future selves, along with the vessels he could gather, to form True Organization XIII.
Take another look at that last part, he planned so far ahead (presumably with future sight) that he had already prepared for everything to fall apart. He even built preparation for future contingencies into his contingencies.
Let's not forget that the significance of the X in each Organization members' names is also explained, along with the gold eyes and pointy ears. If I Nomura hadn't already revealed in an interview that he deliberately leaves elements of each plot vague so that he can fill in details at a later date, I might be impressed this level of forethought. As it stands, just thinking about how likely any one of these events is, let alone all of them occurring in this exact sequence, is mind-shattering.
This is the point where even fans of the franchise question the credulity of the story. Fortunately for Nomura, Kingdom Hearts love the series so much that we (Yes, I still count myself in this group) are still willing to put up with pretty mediocre writing so we can hang out with our "old friends": Sora, Riku, and Kairi.