This is really a problem about failed states, which we know are the source of many terrorist attacks. Most other countries have a very strong interest in stopping the spread of terrorist groups to failed states. But there seems little that can be done about it, for two reasons.
The first is the scale of the problem. "Unfailing" failed states is hard (see: Iraq and Afghanistan). And there are many failed states that might serve as incubators of Islamic terrorism--most of Africa north of the equator, many states in the Middle East, and all of Central and South Asia have areas where the government's authority is modest at best.
The second is the trouble the rest of the world encounters in trying to address the problem. Righting failed states that could house terrorists is a collective good. And we know that states have trouble providing such collective goods, even for immediate threats such as terrorism. While almost all countries want something done about the problem, most prefer that someone else do the heavy lifting.
The United States is a partial exception to this. As a powerful country that has global interests and is an active target of terrorism, the United States has been willing and able to take aggressive action on its own. But even the United States lacks the resources and will to build functioning states (see: Iraq and Afghanistan). So it relies heavily on military force and military aid to local governments. Force promises a quick and relatively low-cost solution. But it carries with it problems as well, such as difficulty in finding terrorists and popular resentment from local populations, which may then tilt towards insurgents and terrorists and away from the United States and its allies.
Are there solutions? Not many attractive ones. The United States could refrain from doing anything in the next failed state hotspot to convince the rest of the world to do more of the heavy lifting. But since the United States is the top target of many terrorists, such a strategy might lack credibility. Even if this is the case, though, it is not clear that doing something (especially when that something involves military force) is always better than doing nothing. Every policy choice involves balancing risks and costs against benefits. And it is not clear that the benefits of military force always outweigh the risks and costs of propping up unpopular governments, alienating local populations, and distracting us from more immediate counterterrorism challenges.