This is a point that needs discussion. We've heard how members of Al Qaeda fought against the Soviet invasion of Afghanistan. Well, I don't believe it. As for the Taliban, they got a reputation for anti-Communism very cheaply, by hanging the former dictator Najibullah - of course, only after it was perfectly safe to do it.
The point is this: it's perfectly true that if America had not taken a stand (led by Ronald Reagan), the Soviet Union would still be riding high and in control of Afghanistan (and probably much else). What I doubt is that Osama bin Laden and his associates were opposed to that outcome.