It wasn't the real 'Ansem.' I think it was a memory of Riku's, If I recall, (because my Re:CoM disc tended to skip cutscenes =_=) forcing him to give into the darkness (as said below me)
The Ansem that shows up in the beginning of Riku's Twilight Town is DiZ, and Riku figures out that he has...