The Guardian first appears during Terra-Xehanort's fight against Aqua, and when Terra appears during the fight so you can do a Trinity Limit, it is the only thing that is there which means it is a representation of Xehanort.
Also after the battle against Seeker of Darkness in KH3D when SoD is "sleep", the Guardian is still there reaching out to Riku.
The Guardian's creation is connected to when Xehanort forces his heart into Terra's body, and the way it appears seems to imply it is a manifestation of the darkness in Xehanort's Heart. It has Heartless features and is the most literal form of "No Heart", the anagram of Xehanort, and I think the most interesting thing about it is all of the X marks made by the bandages on its mouth (symbolism of being silenced, or of blocking the passageway of the soul which is the lifeforce of the body/being. As we know Xehanort has been trying to cheat death so he could continue his plans, and the soul is the key to death in Kingdom Hearts. The mouth has been considered a place where the soul exits the body through the exhaling of breath.)
If it is only a manifestation of Xehanort's darkness or has more connections to Terra, that remains unknown but it is at least verifiable that it is tied to Xehanort's Heart via Xehanort's Heartless/Seeker of Darkness being the only Xehanort entity to have control of the Guardian post the experiments in RG.
Extremely doubt it is related to Eraqus, or existed before the point in BBS when Terra-Xehanort first calls it from within himself.
Well, if Eraqus was inside Terra, then he's inside Terra-Xehanort.