Warning: SPOILERS for Godzilla Vs. Kong.
When Mechagodzilla was activated before the final battle in Godzilla: King of the Monsters, Godzilla Vs. Kong sets the primate ruler of Skull Island against the radioactive lizard in a battle for dominance - until Mechagodzilla rises as a threat to them both and the world at large.
In Godzilla: King of the Monsters, King Ghidorah (designated by Monarch as Monster Zero) was awakened from his slumber in Antarctica by an eco-terrorist group led by Col. Alan Jonah (Charles Dance). The three-headed dragon was revealed to be an alien who landed on Earth millennia ago and tried to become the alpha predator of the Titans. Once he was let loose in the present-day, Ghidorah once again set out to assert his dominance over the Titans that were also reawakening all over the world. With Monarch's help, Godzilla battled and killed Ghidorah in a climactic showdown in Boston. With his victory, Godzilla established himself as the King of the Monsters - except for Kong, who remained in his home in Skull Island under the protection of Monarch, as revealed by Godzilla Vs. Kong.
However, one of Ghidorah's severed heads was purchased on the black market by Jonah; it became the property of Apex Cybernetics and brought to their secret facility in Hong Kong. In Godzilla Vs. Kong, Ghidorah's skull and the latent psychic powers the space dragon possessed were used by Apex to control Mechagodzilla, their ultimate weapon against the Titans. The master plan of Apex's CEO, Walter Simmons (Demian Bichir), was to use Mechagodzilla to kill Godzilla and the other kaiju, which would free the human race from fear of the giant monsters. Simmons even assigned Ren Serizawa, the son of Monarch's late hero and Godzilla er Dr. Ichiro Serizawa (Ken Watanabe) to be Mechagodzilla's human pilot. However, Mechagodzilla couldn't fully activate without the power source from the Hollow Earth that fuels all of the Titans, and this is exposed the great flaw in Mechagodzilla's design.
It turned out Ghidorah's consciousness wasn't completely dead, only dormant within the psychic abilities that Apex was tapping into. When the Hollow Earth energy was integrated into Mechagodzilla, Ghidorah's consciousness reawakened and took control of Mechagodzilla's robotic body. For good measure, Ren Serizawa was electrocuted by the energy , which eliminated the human from the equation. When Mechagodzilla charged up to full power and came online, Ghidorah's mind was totally in control and its first act was to attack the humans it saw in a control tower, killing Walter Simmons, the robot kaiju's creator.
When Godzilla faced Mechagodzilla in Hong Kong, it's not clear whether the heroic Titan sensed or understood that his old enemy Ghidorah was back as his robot doppelganger. But Mechagodzilla's ferocity was evident as the reborn dragon's attack on Godzilla was ruthless and it outmatched and overwhelmed the radioactive lizard. In his new mechanical form, Ghidorah was definitely out for revenge and he had the power to exact it. However, Kong intervened on Godzilla's side and brutalized Mechagodzilla with an ax, which was powered up by Godzilla's atomic fire breath.
When Kong destroyed Mechagodzilla - tearing its skull and mechanical spine out as a trophy - the great ape also achieved a victory over Ghidorah just as Godzilla did in the prior film. Having Ghidorah take psychic control over Mechagodzilla was a sly and cool way for Godzilla Vs. Kong to sneak in a rematch between Ghidorah and Godzilla and, in effect, climax with Kong defeating the evil space dragon as well.