Re: How Time Travel Works
In order to time travel:
1. You need to discard your body (ultimately just becoming a heart).
2. In order to go to a certain place at a certain time, you need to have been there before.
3. You can only move in one direction with the flow of time.
So Ansem SoD, being only a heart since he is just a Heartless, has the ability to time travel. He went to Destiny Islands before it was swallowed by darkness (as seen early on in KH when he speaks to Sora about "worlds being tied to darkness" and stuff), therefore, he existed during that "certain time in a certain place."
Ansem SoD is able to be where Sora and Riku are at during the beginning of their MoM exam because they started off on Destiny Islands before it was swallowed by darkness, which also when Ansem SoD existed there and then as well in the real world, and since he is essentially one of many forms of Xehanort, all other forms of Xehanort are able to join in on the dream crusade in following and harassing Sora and Riku as they travel around different worlds in sleep.
I'm still not clear on how Xehanort revived or whether he revived at all. I've read a few different translations, and some seem to contradict others, so I'm just going to wait until the US version comes out:3
Edit: Oh, Memory Master has a better and thorough explanation. You should just ignore mine and read Memory's XD