Following 9/11, the U.S. found itself in a different kind of war. Not a war with a nation state, but a war with the transnational religious/cultural/political movement that is now called radical Islam or "Islamofascism."
Largely unnoticed by most Americans, this new type of war had been going on since 1989, when the Soviets left Afghanistan. Earlier milestones in that war included bombings of the Khobar Towers, our embassies in Africa, the U.S.S. Cole, and the first (unsuccessful) World Trade Center attempt. Still, most Americans didn't pay attention until jetliners crashed into the World Trade Center and Pentagon.
At that point the question became, "What can we do?" Our military doctrine is designed to counter enemy nation states. We don't have a diplomatic or military doctrine to deal with a rogue social/political/religious movement that exists in maybe 40+ countries, including our own and those of our main allies.
Since we had no idea how to counter an often suicidally murderous ideology that neither controlled nor defended territory, we did what we knew how to do. We invaded the nation state where most terrorists were trained - Afghanistan. Next we invaded Iraq, an Arab state that, while hostile to the United States, was probably not much of a threat. Again, we did what we know how to do, which is conquer a nation state.
Psychologists call this type of behavior "displacement," that is diverting one's attention (or aggression) to a target with which one knows how to deal. We got mad at al Qaeda but attacked Iraq, because we knew how to attack Iraq and didn't really know how to attack al Qaeda.
To date nobody has come up with a feasible solution to the Islamofascist problem. Individuals 'infected' with this ideology can be citizens of countries for which they don't constitute a problem because their enmity is directed mostly at the U.S. Asking those countries to "do something" about such individuals is likely to be futile inasmuch as they have broken no obvious laws at home.