In an unlimited war such as World War II it is very easy to know when one country has won. In an unlimited war one country invades the other’s territory. It pushes the other army back until it has gained so much of the enemy’s territory that the enemy has clearly lost. The enemy generally surrenders at that point. This is what happened with both Japan and Germany.
In an limited war, winning is much less obvious. Winning a limited war is much more about putting in place conditions that will allow for long-term success for the country in which the fighting is done. This can be seen in the cases of both Vietnam and Afghanistan. There, we were not fighting for territory. Instead, we were fighting (and are fighting) to try to support regimes that are under fire from domestic opponents. We can only win such wars when there is enough popular support for those regimes. This is very hard to measure. It is not until we actually leave that we can determine whether the local government (whether it be the South Vietnamese government or that of Hamid Karzai in Afghanistan) can truly stand on its own.
Winning a limited war consists of creating the conditions where a government can thrive. This is not easily measured so it is hard to actually know when we have won such a war.