I think the west has learned (I hope anyway) - and most of us would agree with you - that lengthy COIN operations aren't ideal, especially in countries that don't tolerate an occupation of any kind, even if the foreign occupier truly does only want the 'bad guys'.
However, going into Afghanistan shortly after 9/11 to 'quickly and violently defeat Afghanistan, and then leave entirely' was not an option, the way you describe it. Why not? It is an option, just one that wasn't chosen. They felt they could turn Astan into a free democratic nation.
Counter insurgency, by it's very nature, tends to be a longer and more drawn out conflict that isn't possible to win 'quickly'. If it was simply a matter of firepower & using it to take out bad guys - assuming we already knew who and where all the bad guys were - it would be a bit easier. But, as we all know, it isn't that simple.
And how would you quickly and violently defeat Afghanistan? We aren't engaging in state on state warfare, where we can just go in and destroy as many military targets as possible, as quickly as possible. That's my point. The US should have done just that, and then departed. Hopefully, the Northern Alliance would rise from that and establish dominance.
And while puppet governments tend to be corrupt as a result of the womb they were created in, it's better to leave a 'legitimate as possible, constantly improving' puppet government in place before we leave. Otherwise, who is to say the organization that fills the hole left by the Taliban wouldn't be just as bad, if not worse? Who cares, at least countless lives and treasure would have been preserved. I mean, what is going to happen now anyway? If they turn out bad again and 9/11 part two occurs, you smash them again...
The government we did leave there is fairly weak, and struggles to exert it's authority in many places. Troops and police are of poor quality, and it is quite obvious that many members of government are corrupt, and the money disappears. So while everybody had hoped this government would find it's footing and 'work' - it most likely won't in it's current form..... but holy cow did the west ever try to leave a legitimate government in place before leaving! I think over time, the "occupation" is what eventually turned quite sour. In hindsight, I think a quick departure would perhaps have left a better taste in the their mouths and allowed for the Northern Alliance to establish with far less western animosity to fester. They would have been free to choose their future, not have one forced on them.
We all agree, especially in hindsight - lengthy COIN operations are a no-no for most western countries now. No appetite for it. Which is all fine and dandy with China on the horizon. Agree.
Quickly and violently defeating 'Afghanistan' (I know you probably meant the Taliban). Due to their nature, it just couldn't happen. I meant the country, the country that housed the terrorists and sheltered them. The country that allowed the Taliban to emerge.
And leaving as soon as possible after we kill the bad guys, we are just leaving the power vacuum open to being filled with someone just as bad, or worse. Or, China steps in & commits to stabilizing it, and reaps the rewards down the road. (Which I could see happening anyway) Again, doubtful it would have been any worse than what is about to occur, just with less cost to the west.
My 0.02