If I have $100 then I can choose to spend it on say a book. I have a book, my $100 is clearly gone.
But when the govt spends say $400 mil on a lunar landing, they get the lunar landing, but they also get a bunch of money back. Firstly, a chunk of that money goes to salaries, so a decent chunk comes back as primary taxes (income tax etc) and secondary taxes (sales tax, gas tax, taxes on booze and smokes).
What isn't taxes is mostly then circulating in the economy (generating yet more taxes) while giving the economy a nice boost.
Now we can argue about opportunity cost etc, but the govt has no issue borrowing all the money they like - so there's no real lost opportunity.
We can quibble about edge-case budgets all day long, but its hard to avoid the jobs program that is "military spending". In truth what does all that money buy? The lunar program, the Mars program, curing cancer, these are rounding errors compared to the military budget.
I'm gonna get crucified for saying this, but what do invasions of Iraq, or occupations of Afghanistan for 20 years actually really achieve? Instead of picking on NASA it might be time to wonder what the Defence trillions get us?
Which brings me back to my first point- most of those trillions circle round in the economy anyway, so its all funny money.