Less than two weeks after Shamima Begum was discovered in a Syrian refugee camp, she’s public enemy number one. Eight in 10 people believe she should be stripped of her British citizenship; 65% say so, even if that leaves her stateless.

The home secretary, Sajid Javid, might regard this as vindication of his disgraceful decision to deprive Begum of her citizenship last week. But others have expressed dismay at the level of public vitriol.

However, it is entirely predictable. I think of my first reaction: not compassion, but anger at the abhorrent views she expressed about Islamic State’s victims. If I had loved ones killed by these terrorists I like to think I’d be one of those amazing souls who moves quickly to forgive. But I suspect I’d be in the “lock her up and throw away the key” brigade.

On one level we, the public, don’t have to work through the discombobulating mix of disgust and pity she inspires. You don’t have to deny she is responsible for any crimes she may have committed in order to think she should be brought back to the UK to be held accountable. Once she’s back, we can leave assessing guilt to the courts.

There is a danger in allowing the vilification of Begum to go unchallenged. Turning someone into a monster is a protection mechanism: it absolves us from thinking about moral complexity. It permits us to consign evil deeds to a place beyond the pale of understanding. But we lose something important if we don’t try to understand how evil manifests itself: the capacity to prevent it.

Take child abuse. Studies suggest we view its causes as “deep and immutable”, so evil that it’s inexplicable. That leads us to believe that the only way to prevent it is to find the evil people and lock them up. To see it as preventable through other means, such as therapeutic interventions, which research shows is possible, is to render child abusers too human for comfort. Understanding feels too close to absolution.

In counselling the need for greater understanding of Begum’s actions, some have drawn parallels with the grooming of young girls by paedophile gangs in places such as Rotherham. It’s an analogy that leaves me deeply uncomfortable. Yes, grooming techniques were used on Begum. But in the one case, girls as young as 10 were groomed purely for sexual exploitation; in the other, yes, a 15-year old was married, albeit willingly, to a man almost twice her age. But Isis grooms young men and women to fight for a terrorist force that commits genocide. That’s why I find the “she’s nothing more than a child victim” line hard to swallow. What if someone who was radicalised as a child goes on to commit terrible atrocities as an adult? It’s not a hypothetical; we don’t know the extent of Begum’s crimes, but radicals have committed atrocities in the name of Isis.

Begum’s case reminds me more of a book I read as a teenager – the 1981 novel The Wave, based on events at a California high school. A class of students struggles to understand why ordinary Germans stood by as the Nazis systematically murdered 6 million Jews. Their teacher sets up an authoritarian membership organisation that demands absolute obedience from its members. Things escalate quickly into violence. The story ends with an assembly to unveil the new leader of a national movement to create youth wings across other schools. An image of Adolf Hitler is projected on to the screen. It also brings to mind the Stanford prison experiment, in which a psychology professor randomly assigned volunteers to be “guards” or “prisoners” in a two-week prison simulation. Within a few days some guards were psychologically abusing and torturing prisoners.

The common thread in both is that ordinary people can be induced to act in unsavoury ways, through indoctrination or simulated conditions. And indoctrination is part of the radicalisation process; Times reporter Anthony Loyd describes how Begum displays the hallmarks of other indoctrinated jihadists he’s interviewed before.

For me, the more difficult question about Begum’s case is not whether she should be held accountable for any crimes – of course she should – it’s this: what would I have done had I found myself in her shoes having already made the utterly stupid, dreadful decision to travel to Syria as a 15-year-old? What would I have done as a prison guard in the Stanford experiment? I know what I like to think I’d have done, but can we ever be 100% sure?

Perhaps those of us who have never had our capacity to commit evil under malign influence tested are lucky, rather than pure. That’s one reason to be grateful for the rule of law. Another is that it allows us the luxury of kneejerk reaction because we’re not in charge of meting out punishment ourselves.

But Javid, by weighing in to use powers that politicians have awarded themselves to deprive Begum of citizenship without due process, is messing with that. He’s starting us on the slippery slope to trial by public opinion. And vigilante justice has tragic consequences; one of the worst examples is the man who, mistaken for a paedophile, was brutally beaten up and set alight five years ago. In recent years, eight people have killed themselves after being labelled paedophiles by vigilante hunters.

Holocaust survivor Primo Levi said: “Monsters exist, but they are too few in number to be truly dangerous. More dangerous are the common men, the functionaries ready to believe and to act without asking questions.” Nothing I have read suggests Begum is a monster. I wonder how many of us would be functionaries in the wrong circumstances. We like to think we embrace the rule of law because we’re better people. But what if we’re better people because we embrace the rule of law? That, ultimately, is why Javid’s actions are so troubling.

• Sonia Sodha is an Observer columnist