Giving up in Vietnam was a huge blow to the U.S., especially since militarily we were winning but the press rounded up enough public opinion against it that we abandoned the people we promised to save and left them to their fate at the hands of Uncle Ho's army and "reeducation" camps. Maybe people were looking to prevent the same here, except now it isn't some tribe among a bigger tribe, but the entire female half of the population.
I don't think that was the trigger of the war though, nor was it an electoral stunt. AQ carried out the largest terrorist attack in history on us. To do nothing was to invite more. The organization had to simply be put down. Sure, they have struck since then in Spain, the United Kingdom, and many other places but always on a smaller scale. They are not what they once were. Their strongest leaders are dead or captured, and AQ has fragmented into smaller pieces that are constantly on the run lest they risk being targetted. The problem is, much as we had an opportunity to do after the Soviet Union collapsed, we have an opportunity to nation build, and most importantly, get people an education. The results take decades to bear fruit though, are expensive, and there are no metrics to measure success while such projects are progressing. This is far more complex and difficult than bombing people, so here we are, not doing it.
I think nation building was the way to go, but there has not been the political will to do so, and the longer we go, the more difficult it would be.