And the current struggles of the American military only result in hundreds or maybe thousands of American deaths, which historically, would be a mere rounding error. Afghanistan, Iraq, Syria, et. al. are a mess, but they don't come to a significant human cost to America.
The United States and its voting populace doesn't really care about whether or not developing countries are wartorn, and quality of life is decimated—America and other states have completely destroyed the backbone of several societies in the Middle East and caused the deaths and relocation of hundreds of thousands of innocents, but you don't feel the pain of that when you live states-side. So the country has little incentive to quickly resolve these conflicts besides the bad PR; ongoing conflicts mostly buy time for protracted, proxy diplomacy with other major powers to lay claim to natural resources, and aren't viewed as conflict with a tangible human cost.
So why isn't the US (which has all this tech) winning in Afghanistan over some rebels with AK 47s? Likewise Vietnam after literally a decade of fighting.
Weapons superiority is one factor in winning wars. Likewise, to address the gp's point, the history of political organization is partly driven by military technology.