I don’t think he was fighting for the Taliban. I’m certain he was providing material support with the full backing of his government which our elected leaders have been too chicken to stand up to since 1989.
You’re probably right; we cozy up to Red China after they did the same for North Vietnam as well. It really is nasty, and anyone who enlists in the military with this duplicity going on must have blind faith in a very flawed government (including the last president).