Microsoft could probably look to run things like GitHub at a loss, picking up equity via their integrations and leveraging any data customers publish on GitHub to ingest into their own AI or sell to others.
Sure, but if I wanted to I could also look to run at a loss for pretty much the same reasons. In either case it's a (profit-motivated) strategy to capture and hold a critical market.