IMHO, we established too many goals that had little to do with the reason we were there such as, setting up and protecting a new government that was corrupt and incompetent, seeding democratic principals, building an Afghan military, converting an Islamic educational system into a secular system, establishing equal rights, building trade, and dealing with the opium poppy harvest. Somewhere among all of this, getting the bad guys was no longer a priority.
This is typical in limited wars when you occupy a country, you neither win nor lose. You fight, you die, you spend tons of money, and then you go home and ask your self, what was that all about.
You are exactly right regarding all the nation building b.s. we got involved in. Just a huge waste of money and a misuse of our military personnel who should have stuck to hunting and killing the taliban.
Our casualty rate was low....still we might have been able to keep the taliban out by using fewer troops such as special forces along with more air power and lots of drones.
We occupied several countries after the end of WWII with no problems.
Occupying a muslim nation is more complex though and especially so when a lot of militant muslims live close by aka the tribal lands of Pakistan.
Allowing them safe haven in the tribal lands was our biggest mistake I am convinced.
Now admittedly I do not know how much we really needed Pakistan in the war on terrorism and of course the main reason we allowed the taliban safe haven in the tribal lands was to placate Pakistan.
Yet according to many reports I have read Pakistan played a double game--especially their intelligence agency.
Thus I think our need to placate Pakistan was over-rated.
Not to forget they also hosted Bin Laden.
What we really needed in Afghanistan was not a traditional military commander but someone more innovative and able to think outside the box....the type of people more associated with special ops.
Tommy Franks an Artillery General was probably our worst commander in Pakistan.
I think Trump listened to the Generals too much and he never had the best command structure in Afghanistan.
Also, though I have never even heard it mentioned as a possibilty of forming an alliance with India in regards to Afghanistan...it would have really pissed off Pakistan...the two countries being mortal enemies....However I think India would be a much better ally than Pakistan.....though as I said I really do not know all the facts of the conventional claim that Pakistan was essential to our war on terrorism....one thing for sure they gave us no help in Afghanistan and obviously gave a lot of help to the taliban.