A few nights ago I had a nightmare – my family and I were living on the seventh floor of an apartment building in a US city that I could not name. It was a hot summer night. Through our open windows we heard shouts of: “Go back to where you come from!” This was followed by a commotion, and then gunshots and then death grunts. My daughter was standing by the window looking outside – I crawled to her yelling at her to get on her stomach – and then I woke up relieved.

And then I read about the attack in Nairobi at the Dusit hotel in which at least 14 people were killed.

Briton and American among dead in Nairobi hotel attack Read more

My family and I had been planning to stay at the Dusit hotel next month when they come to visit me in Kenya. It is where we stayed last year and where the winners and organisers of the Mabati-Cornell Kiswahili prize for African Literature stayed in 2016. The shop where my daughter and wife had dresses hand-tailored is just a few doors down from Dusit.

I feel upset and helpless not so much because I think the attack could have happened when we were there, it is more the randomness of it all. Anyone could die, the timing does not belong to us, it belongs to the terrorist. It is this indiscriminate nature of terror that, well, terrifies me.

And that is the point. Unlike revolutionary movements that used violence to achieve specific attainable political goals, for al-Shabaab terror is for terror’s sake. Where South Africa’s Nelson Mandela-led ANC had the all-inclusive and progressive freedom charter, al-Shabaab, Boko Haram or the Islamic State have vague proclamations and edicts. They are most erudite when speaking of violence – think of those well-produced Isis videos of torture and death.

But I also think about the videos released by the Pentagon of pretty, blue-green flare lights over Baghdad – the death and devastation below unseen – or the recent US army tweet during the New Year’s Eve ball that read: “If ever needed, we are #ready to drop something much, much bigger.” Think of what a US drone strike on a wedding party, for example, does to the bodies of women, children and men, and the mental and physical trauma it inflicts on the survivors.

Think of the Israeli Defense Force and the ongoing attacks on protesting unarmed Palestinians that have left 214 Palestinians dead and a staggering 18,000 wounded. Watch this New York Times investigative piece on the killing of a nurse who was out in the protests to help the wounded and decide for yourself who has the monopoly on violence and terror.

To eradicate group terrorism we have to get rid of the state terrorism that feeds stateless terror organisations in the first place. I don’t see any other way around this. Writing for the Guardian in 2013 shortly after the Nairobi Westgate Mall attack that left 71 dead, I argued that al-Shabaab was the creation, in part, of the Ethiopian and US governments.

There was a small window of hope when Somalia had started reconstituting itself under the Islamic Courts Union (ICU) after the fall of the western-sponsored dictator Siad Barre and the anarchy that ensued. But the idea of an Islamic government was too much and the US-sanctioned Ethiopian attack in 2006 on the ICU splintered it, with radical and radicalised elements forming al-Shabaab.

After the 2013 Westgate Mall attack, the Kenyan government went on to do everything it should not have done. Kenyan Somalis became the enemy and were herded into soccer fields, concentration camps by another name. But earlier, in 2011, the Kenya Defense Force had invaded Somalia, ostensibly because al Shabaab had been kidnaping tourists and NGO workers. Never mind that we as a people have yet to fully atone for the 1980 Garissa and the 1984 Wagalla massacres that left thousands of Kenyan Somalis dead.

Writing six years later about the same city, very little has changed. There is a certain feeling of vulnerability and loss of control that makes terror urgent and personal. We need to take the long view of history if any solution is to come about. If we don’t change, if we continue with the terror tit-for-tat, we will be creating yet another set of these manmade disasters.

• Mukoma wa Ngugi is a writer and political analyst