I'm not an expert on Afghanistan (I'm from faraway Africa), but I think the most important lesson, which the West should heed is this:

A nation is a working social contract and US Military might and aid dollars cannot create a working social contract from scratch. You can create the apparatus of a state quite easily, but you cannot create its essence - that is left for the citizenry.

Another thing Americans don't understand is that so many states in Africa and Asia are legacies of colonial rule, they lack working social contracts - and Western aid money, "counter-insurgency efforts" and military intervention CANNOT create working social contracts.

The biggest delusion of the Western foreign policy elite is that "democracy can create a working social contract" - it cannot, classical example is Mali - elections in Mali will do that State no good, it is a nation more in theory than in fact.

The World's many artificial states will have to work out their own "Peace of Westphalia" - and there is absolutely nothing the US can do about it, except try to truncate the process via "intervention".