Islam isn't exactly a religion of peace. It calls for peace when possible but also calls for violence and retaliation when needed.
Also, violent muslim groups exist. And it's a fault to always attribute it to religion (even if it plays a central role in it) as if these groups don't have any political or social motives at all. Heck, most of yall ignore somalis and kenyans have had disputes over territory and Kenyans are far from being innocent. Also, muslims can have a strong community sense and when they see what they perceive as a war against Islam: hundred of ythousands, if not millions of muslims killed and persecuted during the last decades, a media war/offensive..etc, it's not exatcly hard to take it as a sign of hostility and unfortunately reply with violence.
Terrorism and extremism has touched muslims the most and they've paid the biggest cost of all. But this is conviently ignored, as if muslims were a monolithic group.