Well, according to the TV Tropes website, Xehanort is running a Xanatos Gambit (he's even mentioned on the page), which is pretty much a "no matter what you do, I still win" type plan.
So, even though all his previous plans failed, they were all part of a bigger plan that is currently...