Both are examples of defeats due to lack of social and political support by the people, not technology or logistics.
The US barely lost 58,000 soldiers in VN, and only 2,000 in Afghanistan and 4,000 in Iraq.
They could have easily won if the objective had been winning. But I think we all know that the objective in both cases and pretty much in all wars the US has engaged in since 1914 wasn't winning per se.