WASHINGTON — AFTER a terrorist attack like the one in Florida on Sunday, one of the first questions people always ask is: Why? Why would someone take the lives of innocent civilians who are total strangers? That is a question to which I have long sought an answer. But my search has led me instead to another question: Is an answer even possible?

To try to figure out why terrorists do what they do, researchers at the think tank New America and I reviewed court records in more than 300 cases of people charged with jihadist terrorism in the United States since Sept. 11, 2001, ranging from relatively trivial cases, like sending small sums of money to a foreign terrorist organization, to very serious ones, like murder. I have also spoken to terrorists’ families and friends and even, in some cases, to the terrorists themselves.

The easy explanation — that jihadist terrorists in the United States are “mad” or “bad” — proved simply wrong. Around one in 10 had mental health problems, below the incidence in the general population. Nor were they typically career criminals: Twelve percent had served time in prison, compared with about 11 percent of the American male population.

I found that the perpetrators were generally motivated by a mix of factors, including militant Islamist ideology; dislike of American foreign policy in the Muslim world; a need to attach themselves to an ideology or organization that gave them a sense of purpose; and a “cognitive opening” to militant Islam that often was precipitated by personal disappointment, like the death of a parent. For many, joining a jihadist group or carrying out an attack allowed them to become heroes of their own story.

But in each case, the proportion of the motivations varied. For instance, Tamerlan Tsarnaev, the older of the two brothers who carried out the Boston Marathon bombing in 2013, was a nonpracticing Muslim who became an Islamist militant once his dreams of becoming an Olympic boxer faded. At the time of the attack, he was unemployed. For him, bombing the marathon seemed to allow him to become the heroic figure that he believed himself to be.

On the other hand, his younger brother, Dzhokhar, never seemed to embrace militant Islam. He smoked marijuana, drank and chased girls — hardly the actions of a Muslim fundamentalist. Dzhokhar Tsarnaev’s motivations for the bombings were instead largely molded by his older brother, whom he admired and feared, and by his own half-baked opposition to American foreign policy.

Nidal Hasan, the Army major who killed 13 people at Fort Hood, Tex., in 2009, seemed to be a more classic jihadist. He was a highly observant Muslim who objected to American foreign policy. But according to Nader Hasan, a first cousin who had grown up with him, the massacre at Fort Hood was also motivated by Nidal Hasan’s personal problems. He was unmarried, both his parents were dead, he had no real friends and a dreaded deployment to Afghanistan loomed. “He went postal,” Nader Hasan told me, “and he called it Islam.”

David C. Headley of Chicago, who did much of the planning for the 2008 attacks in Mumbai, India, in which more than 160 people were killed, was not an observant Muslim. He juggled multiple wives and girlfriends. He was motivated more by a passionate hatred of India — and his enjoyment in playing the role of a jihadi James Bond, hanging out with Bollywood stars for cover while secretly planning one of the most spectacular and deadly terrorist assaults since Sept. 11, 2001.

These stories underline how hard it is to satisfactorily answer the question of why terrorists commit heinous crimes. Human motivations are complex. As the philosopher Immanuel Kant observed, “From the crooked timber of humanity not a straight thing was ever made.” It’s a useful reminder to journalists and politicians alike that human beings often defy neat categorization.

Given this, how should law enforcement respond? F.B.I. behavioral analysts use a smart framework. They focus on behaviors that show that someone is on what they call the “pathway to violence.” The ideology enabling this pathway is a secondary concern; whether they are dealing with neo-Nazis or jihadists, F.B.I. analysts use actions, not ideas, to determine whether someone might carry out an attack. This approach is agnostic about the “Why?” and focuses on the “What?”: what a suspect of any ideological stripe might be doing along the pathway to violence, like scoping targets or acquiring weapons.

Of course, this is imperfect. Omar Mateen, the Orlando gunman, had been investigated by the F.B.I. twice. But at the time he didn’t appear to be far down the pathway to violence. According to reports, he began scoping out the Orlando nightclub, assembling weapons and trying to buy military-grade body armor only in the weeks before his attack.

We are learning bits and pieces about Mr. Mateen’s possible motivations. Relatives say he expressed homophobic views. He pledged allegiance to the Islamic State during the attack. Co-workers say he also praised Al Qaeda and Hezbollah. His former wife says he was abusive and couldn’t control his temper. There have also been suggestions that he might have been gay.

No doubt we will learn more in coming days. But it’s unlikely that anything will ever really explain why he did what he did. Perhaps that says something about the nature of evil, — that it is ultimately not fully explicable. Even the perpetrators themselves can never really articulate “Why?” in any meaningful way.