Just a few thoughts......
I suppose everything is obvious in hindsight but.......I think that at the grand strategic level the mistake the West did was to take on both Iraq & Afghanistan... Bush manipulated the American public into a war on Iraq by creating a brouaha on Islamic & nuc terror. Hell, the public was so scared & enraged they would have even supported a war on Mexico!!. So you hit the Taliban, then invaded Iraq and inoculated the Talibs with driblet force levels and gave 'em time to reorganise, re-equip, recruit & when they were nice n ready you took them on!! Another mistake from the US side was not to get the Indian Army involved : the 2nd largest army, infantry predominant, CI experienced force who were, are & always will be the bulwark against Islamic terror, and who have traditionally fought the Afghans & Pakis from the earliest of times. True it would have been a difficult ask with India's politicians & Paki generals opposing it but in hindsight the involvement of the IA would have substantially enhanced the ability to dominate physically large tracts of land & consequently the population a sine qua non for a successful counter insurgency campaign in a rugged rural setting. See, whenever u deal with monolithic Islamic cultures (as distinct from where they are a minority) please understand that they have a persecution complex ingrained in them.... it seems to them that everybody is out to kill them, defile their books, women, culture... so they keep working themselves into frenzies and literally explode. It was only a question of time before they turned on you even if you did deliver them from Saddam & the Taliban. Unlike the gloomy predictions on this thread, I dont think that the Talibs or the Pakis are going to find it very easy to take over Afghanistan. As for the insurgency campaigns they are like good wines : take a long time to mature... and you remember them for a long time!!