Wrongheaded policies?
As long as the Soviet Union existed, it was the biggest threat to the West. The United States had to dealt with that threat, even if that meant supporting jihadists. Likewise, the United States previously supported the Soviets against the Nazis, judging the latter to be the greater threat at the time.
As the old saying goes, the enemy of my enemy is my friend.
The US supported group is the current government of Afghanistan, once called the "Northern Alliance". The Taliban/Al Queda group was created by Pakistan intelligence, and consisted of Pashtun tribes who were resentful of the influence of Uzbek groups in the Afghan government.
Osama was not our ally, but rather, a competitor, who wanted to use suicide bombers against the Soviets. Wasn't effective then, because suicide bombers don't get to pass on their learning.