The military does what it's ordered to do by the civilian government and under what rules of engagement it has to operate.
Unleashed from those constrains, our military could've ended Iraq and Afghanistan in months, not years, but we try to fight "nice" wars now.
That is true. But both the Bush and Obama administrations have sought military advice before making decisions. I would figure the military would have told them how to win. I'm sure Eisenhower and MacArthur told Roosevelt what they needed to win and he agreed. There is no sense to stay in wars we do not want to win.