How come it wasn't restored after Sora beat Ansem.
You mean Castle Oblivion/Land of Departure? I was thinking the same thing too on why the world is not restored.
Possibly because it wasn't destroyed by the Heartless (it was destroyed by courtesy of MX) and the ruins didn't end up in EOTW (which didn't even exist yet) or it's just that Xehanort never truly defeats, even after Ansem SOD or Xemnas' defeat and the only way to restore the world is to defeat his real self, MX.
I don't see why it would be restored. It was destroyed by MX, not heartless (like Dwarf Woodlands, Castle of Dreams and Enchanted Dominion)