You are making a mistaken assumption that only unprofitable companies need to fundraise, there are lots of profitable companies that want to raise capital to fund future growth (and their current cash flows aren’t enough).
Also I am very surprised that you named Github as a well run private company. As far I know, they were definitely not profitable (their spend was crazy) which is part of the reason the board took the acquisition offer from Microsoft. I really don’t think they are a good example of a well run private company.
You are correct that only companies that want capital IPO but that is by definition as an IPO is a capital raise. I believe that direct listing is an exception to this.