Unfortunately, I'm not sure you can "prevent" it at all.
I take it on a case-by-case basis. World War II? No. And really, we needed to have that war. Iraq 2? Fuck yes, we could have prevented that.
Well, sure. That's perfectly sane. But I think as a country, from the proactive standpoint, you have to approach thins from the standpoint of, certain specific wars may be perfectly avoidable, but war as a whole is not because you never can tell for certain who may attack you, when, or why. Thus, while it may be desireable for a country not to prepare specifically for a war, that does not mean a country should not prepare for war.
Pragmatically, I agree with you. I'm quite happy with our military being one of the largest on the planet.
The bolded part is what I specifically take issue with. I think that our intelligence community is actually pretty darn good at figuring out who specifically we should be worried about.
And no, they weren't too good about preventing that whole 9/11 thing. I don't have an answer for that, beyond pointing to the fact that they've (hopefully) stepped up their game since then. I just don't think that in general, building up a massive military force
far exceeding any other on the planet is really necessary, nor a wise idea. Plus, it's expensive to maintain, and I think you'll agree that borrowing money from China to do so isn't a good idea, particularly since you've already singled them out as a country to be worried about.
Finally, I'll note that things in Iraq 2 started looking better once we put more effort into diplomacy. I'd have to look up specifics, but I distinctly remember reading about concerted efforts to work with various Iraqi militia groups and so forth, coinciding with the surge around 2007-ish. This doesn't really contradict anything you've said, but I think it worth mentioning to illustrate the value of a nuanced approach.
Again, I agree with much of what you've said.