When Trump left office, the war was long over, and we were occupying post-war Afghanistan with a small force. Like post-war Japan or Germany.
The Taliban did not take Afghanistan. We gave it to them.
Bingo.