In all due respect to Farand who does offer some insights, there are many crucial differences between Vietnam and Afghanistan.
1. American, the big winner of WW2 was flush with success and had a booming economy. But the only real snake in that garden of Eden, was new power alignment in the world and the resulting cold war. The big losers in WW2 were in fact the former European colonial powers who sailed back to S.E. Asia to reclaim their former colonies and found they were no longer wanted. As for the USSR, they had already grabbed most of Eastern Europe and swiftly set up puppet communist governments. And Mao in China had toppled the old government and had taken China, the most populous nation on earth, to the communist side of the the equation. In terms of nukes, both Russia and China had them early on to counter the USA, but the USA had the air force delivery systems and Russia had almost nothing in terms of bombers at the time. That all changed in 1957 when the USSR launched Sputnik. As the USA woke up next morning and realized we were on the wrong side of the missile gap. As the specter of global thermonuclear war delivered by ICBM's became very real. As America hit the PANIC BUTTON. Especially since the Russian economy was growing faster than our economy at the time.
2. In terms of wars, to some extent large set piece battles between major powers like WW2 became an obsolete concept. But in general. armed conflict became ever more frequent. First the Brits lost India which became neutral, the French faced revolution in Algeria while hanging on by their fingernails in Vietnam, but the first real example of communist expansion was in North Korea as the North promptly over ran South Korea. As the first real proxy war post WW2 started. As the USA and a UN coalition of other nations landed troops and starting pushing the North Koreans back to their borders. Had the USA and the UN stopped at that, history may have been different, but somehow North Korea needed to be punished for their aggressions as MacArthur pushed steadily North, into North Korean territory with a goal of the North Korean capital. And instead, in the flat footed surprise of the century the USA found the entire massive Chinese army coming at them. The US retreat started then and didn't stop until the UN armies were pushed back even further South of where they started. And as the Korean war dragged on and on, until it ended in a basic stalemate, the principle was somewhat established, the " free world " had to deter communist aggression. As no land borders changed in Korea. At the same time, the USA faced a crisis of confidence, as the French army got defeated in South Vietnam, from a popular peoples uprising mostly centered in North Vietnam. Even if that uprising was not financed or abetted by Russia or China. The problem then was not that the remaining French puppet did not try to take over, the problem was and remained that they had almost zero support from the bulk of the people in South or North Vietnam. And worse yet that cabal did not care, as they ran South Vietnam for only their own benefit. As for the bulk of the South Vietnamese people, they did what they always did, namely try to eke out a living rice farming. Meanwhile back near US borders, a similar peoples rebellion toppled the totally corrupt Baptista government and suddenly Castro was only 90 miles off shore of the Continental USA. At first the USA was unsure how to react, but when Castro nationalized the banana and sugar industries that had historically exploited the Cuban people, the romance was over. And then to add injury to insult, Cuba allowed Russia to set up missile bases only 90 miles from us. Never mind the fact the "free world" had missile bases even closer to the USSR and in far many more places, it was more than the USA could stand.
So we in the USA were itching for a spot to make our stand against communist aggression and Vietnam became that spot. We may debate, had JFK lived, would he have sucked in, but when LBJ became President due to assassination. Vietnam became the spot to make our stand as they LBJ ego would accept nothing else. At first that escalation was small as the USA began Bombing North Vietnam. As the resultant justification in the domino theory began. As the domino theory stated, if we in the USA allow Vietnam to fall, all of the other South East Asian nations like Cambodia, Thailand, Burma, and Laos will fall to the commies one by one. As China told us we could try the bombing, but if the USA put a boot on North Vietnamese soil, their army would intervene to push us out. As a little bombing did not work, LBJ redoubled our efforts, and soon we had 500,000 ground troops in Vietnam that did nothing but alienate the South Vietnamese people. As the USA was soon sending US draftees in droves who understood nothing about how to fight or win an insurgency war in a totally foreign country. As soon mothers and fathers all over the USA got those telegrams that their son had lost their life fighting for our country. I can remember some weeks when 300 or more US parents got their notice their sonny boy would soon come home in a box.
As an initially popular war became suddenly unpopular fast, with a huge component of that was the draft. And as the ego in the Vietnam transferred from LBJ to Nixon, at least Nixon ended the draft to buy off part of the opposition. Meanwhile the US bombing of North Vietnam continued unabated and with zero results. Until Nixon, the morally bankrupt fool destabilized all of South east by putting US ground troops in other South-east Asian nations which backfired big time. Then when Nx0n got re elected in 1972, he adopted the McGovern peace plan, called it peace with honor, which allowed us to sail home defeated while we cried yippe we won.
As for the ole domino theory, not one South Asian country went hard core communist, but all the surrounding South Asian nations became destabilized. Cambodia had its killing fields, Burma went into a military dictatorship its finally starting to end. As for Vietnam, its population is increasing at a rapid rate, its at peace, yet it never been able to join the other Asian tiger economies.
But still, Vietnam was a blow to the American psyche, all that blood, treasure and effort bought us nothing. And even if America can do anything and
put a man on the moon, but could not win in Vietnam or win the heart and minds of rice farmers whose technology had not changed in a thousand years.
I submit there was a lesson we in the USA should have learned in Vietnam and somehow we have failed to learn that lesson even today. As the USA has lost every military occupation since and for the same exact reasons. As we pretend the government are the people, if we control the government, we control the people. In Vietnam that was a giant mistake, as the South Vietnamese government was a small group of ex-colonial officials that controlled a small and poorly motivated military. As the South Vietnamese government didn't care about their people in any way, and the South Vietnamese people didn't much care what that pack of thieves were doing either. As the US had a top down strategy, and the insurgency never makes that mistake. As they have a bottom up strategy, control that people, treat them with some respect and sometimes tough discipline. And then the insurgency can even tax them. But the insurgency has a direct and even more important, a permanent connection with the people the US military almost always lacks.
Now to avoid the mistakes of Vietnam by allowing the war to get too big and bloody, we screw our own pooch even worse. As we come in to all new quagmires with guns blazing, lordie we are in love with shock and awe, as the existing government will be toast within a week. But just when winning the war is over, and the harder job of winning the peace starts, we are woefully unprepared and that is where the USA always loses. Because the the military occupation has to replace the old government, provide basic law and order, often it needs to even feed the people, and replace basic infrastructure. And that takes a lot of troops. Instead we are far too tardy as we get beat by the very anarchy we tow in our own wake. Meanwhile the insurgency can form up in as little as a week as they get ever more popular as a function of the ineptness of the military occupation.
Its the same mistake we in the USA make every time. As we take the same losing strategy and apply it to our next military occupation, and then can't figure out why it never works.