Musk is making a laughingstock out of NASA.
Government and science are incompatible.
The government (aka public funding) funds all sorts of technology for national security and public health that could not be profitable for various reasons. Profit is NOT always necessary for a technology to benefit mankind and create good will.
NASA is merely an agency that hires various contractors at the lowest bid including SpaceX. Musk and SpaceX just have better marketing so they attracted more investors partially thanks to the internet (which was also created by the government for national security long before profitability). Most of SpaceX profit was from NASA contracts until the success of Starlink.
SpaceX utilized public domain and expired patented technology that was was funded by NASA. It cost many billions of taxpayer dollars to perform the destructive testing to obtain the data since no computers could model it. Further SpaceX engine developments since then are trade secrets to protect their profits so they are restricting future development by other entities even though they greatly benefited from public money. Musk did very similar with government electric car subsidies.
NASA I agree has been a laughing stock for decades due to ridiculous policies. Russian rocket engines were the most efficient in the world until 2019 release of the Raptor engine.