People developed these great environments like EMACS and other open source software out of passion, not because they were chasing profits. There are many instances where seeking profits, as in the corporate world, reduces innovation and creates a short term mindset. A lot of the best research comes out of state-funded labs, even the development of the transistor and the computer in the USA, the development of the internet, all funded by the state.
You're painting with broad a brushstroke. Both good and bad things
emerge from the public and private sectors. Despite often falling into
the "worse is better" trap, self-interest is our species' most potent
innovator, modulo purgative events like WW2 when all our intellectual
capital returned to the state.