Vietnam was a civil war, and a proxy war. The U.S. couldn't win because
1. The Vietnamese people were fighting amongst themselves, basically. It was an internal conflict, and there was no good way to separate out who was fighting for the North, and who was fighting for the South. The South was constantly being infiltrated as a result. The U.S. needed a strong dictator in the South who could control the army and whip the South Vietnamese into fighting shape. For whatever reason, unlike the Korean war, such a dictator never appeared on the scene in South Vitenam. Probably the CIA-approved assassination of Diem had a lot to do with it. All subsequent Vietnamese leaders knew that they had to do whatever the US wanted; this made them weak in the eyes of their own people. A strong leader could not emerge in such a situation, only somebody willing to be a puppet of the US. The South Vietnamese army remained a corrupt and incapable institution. The North Vietnamese had worked for a long time to infiltrate the South, and the final withdrawal peace agreement that the US signed and force South Vietnam to sign - the "leopard spot" treaty, basically allowed the North to retain all the areas that they controlled already in the South. This was just a roadmap for the day that the North was going to come in and roll over the South with their tanks. The US never built up a strong enough government or army institution in the South that could withstand the North by itself. Korea was a civil war and a proxy war too, but it was fought more conventionally, and the S. Koreans had a brutal dictator who started and finished the war and kept the S. Koreans in line throughout.
2. As a proxy war, Russia and China were going to supply the North Vietnamese with an endless supply of all the high tech weapons they needed to make victory impossible for the U.S. The longer the US fought in Vietnam, the more weapons the USSR and China were going to pour into Vietnam. The US could never shut off the supply of weapons to N. Vietnam, unlike in WWII, because they would have had to declare war on the USSR and China. The U.S. did the same thing to the USSR when they invaded Afghanistan in 1980.
3. The US thought the war in Vietnam was to stop Communism. It was never about Communism. Right after N. Vietnam invaded and took over South Vietnam, they got into wars with the Khmer Rouge, and then China, both supposedly on the same Communist side. This bipolar view of the world that the US had at the time was totally wrong. It was all about nationalism, and historical cultural disputes. Communism had almost nothing to do with the war in Vietnam.
4. Nixon figured he could sign the crappy "leopard spot" peace treaty with the North Vietnamese and still enforce it - had they invaded South Vietnam while he was in office, he would have sent the B-52s in for sure. But Watergate intervened, and Ford was too weak to send the B-52s in. After the peace treaty was signed, and the US withdrew all its troops, there was a period of peace where it almost looked like South Vietnam was going to make it. Then Nixon resigned, and the North Vietnamese saw their chance - they knew the US was too distracted and anguished by the Watergate scandal to do anything more in Vietnam. They sent their regular army in full force, with tanks rolling into South Vietnam. A real blunder, that the US had not anticipated this possibility and given the South Vietnamese Army massive quantities of the anti-tank weapons they could have used to fight off these tanks. Nixon was counting on using American forces to respond, and this just never happened. American air power would have easily crushed the regular army force that the North sent in, especially the tanks.