There are two reasons you battle Xemnas three times in Kingdom Hearts II. From a design standpoint, most J-RPGs give their final bosses multiple forms or phases, and Xemnas is no exception.
Within the story, it's because he's absorbed Kingdom Hearts itself, granting him enormous power. That surge lets him keep fighting and transforming after each round, forcing you to face him again and again.