There is no comparison. The Communists won the war because they could freely use Laos, and Cambodia for logistical bases. The front line in Vietnam was 800 miles long, which is almost twice as long as the Western Front in WWII. The NVA could cross into South Vietnam anywhere, and anytime they wanted to. After defeat they would retreat back into a safe zone, to regroup, resupply, and start all over again. They used the same routes to supply, and reinforce the VC inside SV. If the American Army moved into Laos they would cut the Ho Chi Minh Trail at it's base along the 17th Parallel, extending the DMZ Westward. The Communists also moved supplies into Cambodian ports, that the USN could block, by searching incoming ships.
This is called isolating the battlefield. With their supplies cut off the VC could only count on what they could capture, or buy though corruption, which would be far more limited. The ARVN could then concentrate most of their forces on counter insurgency, rather then fighting the NVA. The Americans, ROK's, and Australians would deal with the NVA in the North, fighting a conventional war. No GI's burning villages, herding peasants into Strategic Hamlets, or the dropping napalm on kids.
The Soviets lost in Afghanistan, because their use of geocidal tactics turned the population irrevocable against them, along with most of the Islamic World. The Mujahidin had safe havens in Pakistan, and Iran, with supplies, weapons, and volunteers from Muslim Countries, and sophisticated weapons from the CIA. China also supported anti Soviet factions in the NE part of the country. The Soviets never had the option of invading Iran, or Pakistan. That would be beyond their military capacity, and would only multiply their problems. Both China, and the United States would intervene to defend Pakistan, and potentially start WWIII, with the USSR & India vs. USA & China. invading Iran would only create another quagmire.