Correct, github sold out to investors, which then owned them, which then sold them out to get an exit when it turned out the company was in no shape for an IPO which is the only reasonable other exit if you are looking for a 10x ROI on a company that burned through hundreds of millions. Investors were in this for a huge exit and they just got it. In fairness, MS bought a valuable social network of essentially the entire OSS and developer community.
As an independent entity, Github would have had to evolve in a very different way and gone more aggressively after making money, fixing their cost structure, like most of their competitors like Atlassian, Gitlab, and other companies selling developer tools as a SAAS service. So, even though these are comparable companies with comparable offerings, the value proposition is very different. There is no way in hell Gitlab is worth anywhere near what MS just paid for Github.
Being based in silicon valley means Github paid a premium for being there and burned through loads of cash paying for expensive developers, fancy office space, etc. Much cheaper if you are based elsewhere, have less emphasis on wanting to have every OSS project on your platform and more emphasis on selling tools to corporations. This is in a nutshell the strategy for Atlassian and Gitlab. Both also offer freemium layers for OSS but mostly their deal is upselling to their paid offerings. Growth that way is much slower. Though, I would say, Gitlab is now pretty well positioned to succeed where Github struggled.