Many, many pages can be written about this subject but I'll try to be brief. Here is France we have many muslims, most of which are perfectly normal people who wouldn't cause harm to anyone. But they are also a community who doesn't integrate, no matter what anyone says. They keep to themselves and try to live at the same time in both worlds, keeping traditions and views that have no place in a modern society, such as the way they view women, but at the same time wanting to exist in a capitalist, materialistic modern world.
Here in France after the second world war there was a huge need for workers to rebuild the country. Many of those workers came from Portugal, Spain and other european countries, and those were able to fit in just fine since they already had the same social values.
Many others came from the french colonies in Africa: countries like Algeria and Morocco, of muslim background. Those people were all piled up into ghettos, built outside France's biggest cities, where they've been living ever since, isolated in communities where nobody wants any contact with. The french didn't accept them because they couldn't relate to the muslim mentality and muslims didn't make any effort because in the muslim culture you don't change yourself, you force others to change in order to fit in your box, and I don't mean this in an offensive way, it's just what it is.
The children of those people were born in France and have french passports but they are not french since they don't share the culture. They try to fit into the culture of their ancestors and please their families and at the same time they have to live in a modern european country. They don't have an identity and they feel powerless. For many of them life is not what it was promised to them growing up. Suddenly they are young adults and they don't belong anywhere so they become easy targets to radicalism.
They become terrorists for the same reason elsewhere other young men join gangs. being part of a terrorist organization gives them a sense of identity and power, even if that power is to murder innocents.