War in Afghanistan is not a military affair but a political one. The soviets left the coutry because they realized that their political goal was impossible to achieve and most of the population were against the government. So, to stay and fight would be useless.
Nowadays things are a little bit different. NATO and other international stakeholders are performing reconstruction projects to help population and "win hearts and minds". The army, as far as I know, has been performing well and for instance, the last major operation in Arghanbad district, a week ago, was performed mainly by Afghan troops supported by Canadians.
But things are not perfect and may change for the worse.
The Karzai government is still heavilly dependant on foreign help and cannot perform with authonomy;
Slowly by slowly the war is taking its toll on foreign troops, and as we know, Western people is less willing on taking casualties as it was 60 years ago;
More important, any Western military débacle is likely to show on Al Jazeera, no matter how insignificant it may be. And the image of burning vehicles and dead soldiers will have a disproprotionate effect on public opinion if compared with the real military loss.
So, things are not all that bad but the West has many drawbacks, and these can turn a stabble situation into a defeat.
And lets not forget a crucial dogma: for a guerrilla force to succeed it only needs to stay alive while for a conventional force to succeed it has to destroy the guerrilla.