Question: how are ansem and xemnas alive?
Answer: After Riku defeats Ansem, Seeker of Darkness, he's brought back to the real world and out of the realm of sleep. When Sora arrived at The World That Never Was, he was in the real world and out of the dream. ... Xemnas and Ansem, Seeker of Darkness are back due to time travel.