I'll tell you exactly why Canada, the US, Britain, the Netherlands, and Australia are failing in fighting the Islamic factions in Afghanistan. Valleyism.
Think of this. You live with your tribe in a mountain valley. You have your own way of life, your own beliefs and practices and customs (however barbaric). Invading armies (We defenders of democracy and freedom) then come into your valley and try to change your way of life. What do you think the response will be? Pick up a gun and shoot.
Military defeat of the militant Islamic factions SEEMS like a logical step in Afghanistan because it has worked in the past in very different places. We defenders of democracy and freedom entered Nazi Germany and defeated it and liberated oppressed peoples. This is a much different situation and a much more complex one in Afghanistan.
The difference here is that in Nazi Germany, we liberated people who embraced the same values we do and supported our cause. In Afghanistan, we're largely seen as an enemy who is propping up illegitimate puppet governments.
In Afghanistan, it's basically a culture war between the urban, secular Muslims in the major cities, and the rural, highly fundamentalist religious Muslims in the tribal areas. We have the urban guys on our side for the most part. But by entering the rural areas, we open ourselves up to attack and are seen as oppressors and invaders. If we stay out of the rural areas, if we stay out of these peoples' mountain valleys, valleyism no longer applies and they are forced to take the offensive and cannot be legitimately seen as defenders of their valley if they're attacking people outside of their valley.
Afghanistan's army needs to be trained, no doubt, in order to combat the insurgents themselves. Instead of fighting the Islamic factions in the rural areas (to no avail), we should be protecting the urban centres and building lots of infrastructure there if we are to be more successful.
All we're doing is supporting one side of Afghanistan's civil war. And it's more complicated than I presented here. Not only is it just urban vs. rural, you have different ethnicities combating each other too, like the Tajik and Uzbek minorities. The Hazara are getting slaughtered. Pashtuns are fighting Pashtuns.
And who do we support to lead Afghanistan? Pretty much every "politician" in Afghanistan is either highly corrupt or a war criminal. If we support anyone to lead Afghanistan, we support essentially a war criminal or someone highly corrupt (And this would be a repeat of the American installation of Saddam Hussein in Iraq to combat Iran and Iranian-supported Kurds...I don't need to re-iterate what a mistake that was).
Instead, I would support the UN effectively running the government until it is stabilized. Or perhaps a bloc of Islamic nations so that it seems more trustworthy to the people of Afghanistan, though I'm not exactly certain on how that'd be received there.
...What we're currently doing in Afghanistan isn't working. And lots of people are dying because of it. We need to change tactics quickly. We won't defeat the militant Islamic factions in Afghanistan without the use of genocide. When we kill one militant, we make five more willing to avenge the death of the one we killed. We need a smarter policy in Afghanistan.
I don't think it's just the Americans in Afghanistan who are hated by the people at large. I think it is the entirety of the international forces there.