He's consumed by political image (and his love of Islam). He thought that by removing US presence from Afghanistan he'd get a 3-fer:
* Bringing the troops home, solving the Bush misadventure
* Weakening US leverage against the potential Caliphate that is forming
* Leaving any blowback as a mess to be blamed upon a future GOP administration
Now that it looks like a collapse would occur more rapidly and be blamed on him, he extends the mission. That's how I see it.
It is all about him.
He has no concept of American loyalty or citizenship.