you have to understand that religious fundamentalists are fucking crazy, they have zero fear of dying for the jihad or some shit, and are willing to hide in fuckall nowhere in squalid conditions for decades, which is why we could never properly beat the taliban.
It's a very complicated web of reasons why the Taliban could never be fully eradicated in Afghanistan. Should be noted that the US never classified the Taliban as a terrorist organization due to desiring diplomatic flexibility with them, but the biggest crux came for mission creep to nation build with the assumption that eliminating the country acting as incubator for terrorist organizations staging ground would thwart future 9/11's as well as the inability to operate within Pakistan. Before the invasion, we wanted the Taliban to hand over top members of Al Qaeda, especially Bin Laden, they declined to do so (Al-Qaeda exerted great influence on the Taliban in the late 90s), so we went in, dismantled their hold incredibly fast over Kabul and the surrounding provinces, but couldn't find the senior leadership of Al Qaeda, so figured to nation build a land locked mountainous country - an artificial state traced back to The Great Game in the 19th century - that was wedged between a very dubious Pakistani "ally" to the East and a bitter Iranian enemy to the West. Both of which undermined us to death as the Taliban kept border crossing throughout Pakistan while Iran went from almost going to war with the Taliban in 1998 to switching to a double-track policy of being friendly to the new government while also secretly funding/training elements to act as a headache to NATO forces
Pakistan in particular was trusted too much which played a significant role in us staying in Afghanistan for so long. They held leverage over us since we had to use their airspace to get into Afghanistan, which in return we couldn't apply the needed pressure on them to maintain and dislodge the Taliban and Al-Qaeda training camps within their borders. It's still up for debate whether or not if the Pakistani intelligence service (ISI) was extremely incompetent or had senior members that knew the location of Bin Laden yet refused to lend this info at an earlier time. Never forget, Pakistan financially supported the Taliban before 9/11 because of
"strategic depth" against India which mind you is still a very relevant reason why Pakistan is at war with the Taliban now as India is becoming a pragmatic diplomatic partner to Afghanistan which Pakistan has accused of the country being
colony of India . And the 2nd in command of Al-Qaeda (al-Zawahiri) only was killed recently in 2022 after we left because he assumed it was ok to return from hiding in Pakistan just to be droned in Kabul.
And never forget that Bill Clinton had passed up
multiple opportunities to kill Bin Laden during his administration. In 98, they knew exactly where he was in a compound in Kandahar, Afghanistan, but there was a risk that 200-300 causalities would take place, so Clinton declined doing so under the notion of being
"no better than him"