Shinji Matou, Gilgamesh, and Cu Chulainn appeared at the same time because they were now on the same side.
Cu Chulainn's Master was Yanfeng Qili. Although Yanfeng Qili had never shown himself, he was an undeniable force in this Holy Grail War. He was both a Master and the supervisor of this Holy Grail War.
Furthermore, because Yanfeng Qili had participated in the previous Holy Grail War, his Servant back then had been Gilgamesh. During the final battle, the Blood Gate Adventurer Team had needed to set up their artificial Holy Grail plan, which required the Holy Grail to become corrupted. Only after meeting that condition would they have had any chance of creating an artificial Holy Grail.
For precisely that reason, Stan had once led people in purging the Fourth Holy Grail War. They had slaughtered all the unaffiliated Contractors and pushed the plot's progress to the final battle, allowing the Holy Grail to become corrupted smoothly.
For the same reason, Gilgamesh, who had originally been a Servant, gained a physical body. He was now a human with demigod traits plus the power of a Servant.
As for Yanfeng Qili himself, he no longer knew whether he was dead or alive. His heartbeat had stopped, yet his bodily functions remained perfectly intact.
After the Fifth Holy Grail War began, Yanfeng Qili summoned another Servant, namely Lancer, Cu Chulainn. As for Gilgamesh, he no longer counted as a complete Servant. Because Yanfeng Qili found him interesting, Gilgamesh continued to act alongside him.
Therefore, Yanfeng Qili, Gilgamesh, and Cu Chulainn belonged to the same faction. Cu Chulainn was controlled by Yanfeng Qili, while Gilgamesh merely cooperated with him; there was no superior-subordinate relationship between them. However, most of the time, Yanfeng Qili still had to respectfully address Gilgamesh as the King