One is that the big machine for war is what allows you to feel and be safe, by making sure you don't get attacked, and making sure no country can deprive you of the necessities you need, thus allowing you to invest yourself in things that aren't related to your safety, like this kind of research.
And the second one is that we owe a giant lot to research done for the purpose of war. That we're having this conversation currently, on computers, through the internet, which I use by wifi, in a french home powered by a nuclear reactor ... War research is one of 3 big misappreciated sources of research advance along with fundamental research and space research, amongst the ones that many people often calls out as "doesn't bring anything / we could do without". Like it or not, we're competitive organism and we're at our best on that front when threatened or when trying to steal others's resources.
With that said it is all a matter of measures and balance, and assuming you're american I agree that the US went completly overboard on that military spending front. Having the know-how to make carriers ? Yes. Having enough carriers to ensure you're safe, that nobody can push you around and that you can push someone else around if need be ? Yes. Reaching that point and then still building some more ... Well no.