The terrorists were motivated by their religious fervour (they were yelling "God is Great")
I think we all umderstand that only a minority of Muslims in Europe would resort to violence, even if they feel very angry or offended by the same issues.
Once terrorists committed the crime, then their religion becomes irrelevant and they are subject to the law, the same as any other criminals.
Avoiding future atrocities in the short term would probably involve more resources for intelligence and security, together with continuous support by community leaders.
It is essential to allow free debate and for the authorities to reassure the wider public that something is being done.
Long term, in the UK we need to discuss how a secular society and a religious minority with some completely different - sometimes alarming - attitudes can more comfortably co-exist.