I agree with much of what you say - Vietnam was one that could have been won, or at least strung out for longer. A decent Govt in the South would have helped. I think
Yemen and Afghanistan are more difficult - they all fight each other at the drop of a hat but if a foreigner appears they're turn on them first - I've known families like that
And when it's everyone against you, not organised forces, it becomes hard to wipe out the whole country