And yes, they do tend to be 20-year-old males. Others can be poor, and unlikely to be able to get a girlfriend or wife.
Its not about desperate individuals, but a desperate community. The communities are often desperate because of poor governance, but you can't unilaterally bring good governance to the Middle East (or any other region).
Actually, there's a lot of reasons why communities are desperate. But a lot of those are hard problems, which are taking time to solve.
At the moment, men are marrying later than women, and chasing overseas brides. Brides sometimes come from Vietnam, where the girls outnumber boys and the culture is somewhat similar; also men occasionally marry African women, as China is now doing more business there; though there's a hell of a lot of racism in China towards anyone with darker skin than average. Also, men are expected to buy a house and car before marriage, which isn't great for men from poorer families (the boys parents usually foot the bill, as few men in their 20s can buy a house). Actually, the costs of male children is starting to reduce the prejudice a bit.
It will raise the crime rate, and cause social disorder (young unmarried men are the kind of people who throw molotov cocktails at authorities - and no authority wants that). China knows this, and has softened the one-child policy a lot. Women used to be forced to abort subsequent pregnancies; now they are more likely to face a fine. Also, prostitution is widespread.
People prefer order to chaos. Order brings prosperity and security. But when there's no hope of prosperity or security, people start to look for ways to change the political landscape to improve their chances of surviving as a group. The closer they feel they are to having their lives or culture or way of life annihilated, the more desperate they become. (It's worth noting that you can manufacture greater desperation in the minds of people around a kernel of real desperation, which makes for an effective recruiting tactic, especially among the religious)
If you want to stop terrorism, you must work to end the source of their desperation. Once you remove (or diminish) the desperate from the equation, the insane will neither be able to form numbers of any notability, nor secure the goodwill of others. They will be treated as they are: criminally insane.