Unlike Iraq, I've run into very few people who say our invasion of Afghanistan was a mistake. Many of al Quaeda's training centers were located there, and al Qaeda's main support structure (the Taliban) was and still is based there.
But as with most other U.S. foreign policy decisions since the end of WWII, our actions in Afghanistan prior to 2001 amount to mass insanity, or stupidity. Your choice. In 1979 the Soviet Union invaded Afghanistan for precisely the same reason we did in 2001, but instead of supporting them, our government boycotted the Olympics. They put Osama bin Laden on CIA's payroll, helped him assemble a mujahideen (which eventually became al Qaeda), and shipped 65,000 tons of munitions to them by 1987. Brilliant, no?