It can work out well and it can fail. While experiments like Japan's fifth generation computer may have failed to produce commercial results, it still trained a generation of very able scientists. Without the significant spending of the US government, the Silicon Valley would not exist in its current form either.
During a time when software and hardware applications had no large market, the military and the government where essentially the only large consumers of the American businesses that are now hundreds of billions of dollars large.
Entrepreneurs in the US love this renegade story of somehow being less dependent on government support than anyone else on the planet, but it's revisionist history. A lot of American commercial success in IT has its roots in government funded programs and consumption.