100% they tried. Can‘t imagine Google and Amazon not wanting GitHub.
But with regards to big acquisitions, MS is ironically and quite surprisingly able to fly under the radar in terms of antitrust. Literally every other tech company is not.
I'd guess its a bit less irony and more that by virtue of having already been through various high-profile antitrust investigations, MS is somewhat uniquely well positioned to understand how to avoid/manage similar scrutiny in the future.
Microsoft can see a lot of data which means they can have plenty of dirt on people involved in anti trust stuff. Beyond certain point companies can do what they want.
A lot of the giant companies are really concerned about anti-trust. Microsoft is under pressure too, but there would be an uproar if Google or Apple bought given their pressure around the app store. Having access to the code that writes the apps would be tough to pull off...