So, for one, I'm not arguing the
outcomes of these wars was good. Rather, that (a) the intentions may well have been good, and also (b) we would really need to compare to the counterfactual of these wars not happening in the first place. Then there are also mitigating circumstances.
Vietnam wasn't started or even fanned up by the US, but rather by the French. The US "inherited" an awful situation. And lest we forget, North Vietnamese did awful purges to the South Vietnamese after the war.
Afghanistan to me is the least ambiguous of them, at least in the early years. US was attacked by a terrorist unit, given official shelter in Afghanistan, whose government also refused to give them up. Not just that, but the propped up regime did things we care about as good. Since NATO withdrawal the Taliban brought thei own variety of peace and associated poverty, and it's not particularly good either. Sure, not a deadly war, but not exactly a niceout come either.
Time and time again the West, lead by the US, faces the nasty choice between seeing evil be done and standing by, or intervening, by means of war, to protect some notion of goodness. And yes, mostly this failed - and maybe the lesson is, don't get involved. But I don't think it's a straightforward a priori obvious thing.
Oh, and if you say there are no "baddie" countries, that just means you aren't familiar with being invaded by one. It's not immutable in time, tables turn etc. But just read up for 2 mins about say Russian atrocities in Ukraine and you may well think warmly of the other wars.