here is the composition of terranort: terras body, made live by xehanort's soul, commanded by xehanorts heart, and terra's heart is also in there, but it is being held down by xehanorts. xehanort has great skill with controlling the darkness. over the course of BBS, xehanort was building up the darkness in terras heart so that when he posessed terra, he would be able to use terras darkness to hold down or otherwise control terras heart. however, terras heart ended up being able to resist xehanort better than MX expected. (due to eraqus's presence in terras heart) i believe that what happened in the battle aqua v terranort is this: xehanort used terras darkness to turn his heart into a heartless, but terra still resisted, even as a heartless. perhaps xehanort was not "summoning" the guardian, rather he was trying to expel it (note that it comes out of his chest) so that he could still have enough control of terras body to fight aqua, and due to terras new heartless nature, he couldnt help but aid xehanort. this "terras heartless" theory is also supported in the cutscene after aqua defeats him. xehanort says: "stop fighting back!" speaking to terra. he then says: "this'll teach you... get out of my heart!" and stabs himself with his keyblade, attempting to force terra from his body. immediately after he stabs himself, he drops the keyblade, and the guardian appears behind him. I'll link a video of this battle and cutscene
here for reference.