Stopping terrorism is pretty simple in theory: You teach your kids to respect other human beings and stop tolerating violence. But clearly this is easier said than done. Until humanity as a whole evolves into some happy hippy Star Trek world with no want, competition, or disagreement, where everyone lives emotionally fulfilling lives and tolerates one another in harmony, there will be some degree of violence.
Practically every theory of terrorism fails on some count. One of the most common arguments is that western involvement in the Middle East (for example, aid to Israel and US troops in Saudi Arabia) fuels terrorism. That argument fails because many culturally incompatible nations such as Japan and Korea hosted US troops and substantially transformed their cultures to compete with the Western world. There are deeper issues involving sectarian fanaticism, resource scarcity, corruption, tribalism and geography that prevent Middle Eastern countries from making the same top-down cultural evolutions you see in, say, Japan.
The claim that terrorism is a reaction to US aggression and bombing is straight-up nonsense. If terrorists wanted revenge on America, they would attack America. Instead, they attack other Muslims. They aren’t fighting the West, they are just fighting for power like any other criminal. Furthermore, many of the terrorists who struck in the West come from wealthy and well-educated backgrounds; They did not suffer any mistreatment at the hands of Western militaries whatsoever.
The claim that terrorism can be explained by relative deprivation theory is closer to the mark but also fails. This theory holds that poverty gives rise to frustration which causes impoverished to violently lash out at the whomever they blame for their condition. This might be true in some cases, but fails to explain why comparatively wealthy people with every advantage in life still decide to become terrorists.
As far as I can figure out, the only thing all terrorists have in common is that they are unhappy about something and think acts of mass violence will make them feel better. Also, they all deserve to be shot in the face.
My last point on the subject is that some people (such as Robert Kaplan) believe that there is a deterministic role in geography itself. That is to say: Areas that are sheltered by clear and defensible natural boundaries (much of Europe and the US, Japan, etc) have a decided advantage in producing comparatively stable and homogeneous states. Border regions that lack definitive geographic boundaries (the Balkans, the US-Mexico border, the FATAH, the entire Levant) will always be chaotic and will never form stable and defensible states. People who try to control it end up imposing draconian measures (such as claiming to build a giant wall… essentially, claiming they can create a boundary where none exists) or they react with an excess of brutality (the same way Saddam had to resort to brutality to impose control over Iraq). If this theory is true, then there are certain regions that will always be in chaos no matter what, and we might as well get used to it.