We screwed ourselves on Afghanistan by invading Iraq.
Think about it this way: if you intervene in a country, the goal is to get out having replaced the existing regime you don't like with one you like better. You Brits were really good at this. It's how you built an empire. Your SOP was to approach the most powerful group that was out of power, and offer them the opportunity to be in power in return for policy concessions. You got in, left some troops behind to make sure that the new regime didn't screw it up, and got out.
This is hard to do in Afghanistan due to the terrain. The most powerful group understands that they just need to go to ground in the mountains, and harass the foreigners until they get tired of the harassment and leave. The most powerful group then just reasserts itself, and life goes on like nothing happened.
You lot tried three times in Afghanistan at the peak of your powers and failed. The Soviets failed. We failed. If you want to win, you need enough elite soldiers to dig the resistance out of the mountains. We pulled ours out of Afghanistan to invade and pacify Iraq. That worked a lot better, because Iraq doesn't have the mountains.
By the time we sent our elite soldiers back to Afghanistan, the Taliban had recovered enough that there was no digging them out of the mountains.
So we failed. It's not that hard to understand if you have some command of history, but the political masters of armies tend to get there by trampling political opposition even in the special cases. As a result, they tend to think that military special cases are just as easily overcome. If they are smarter than that, they don't invade Afghanistan in the first place.