“It’s depressing, it’s saddening and, in many ways, it’s infuriating,” said Neal M. Sher, a lawyer representing victims and their families in the first Fort Hood attack in an ongoing lawsuit accusing Pentagon and federal officials of knowing Major Hasan was a security threat and failing to act before the attack. “You would think that one place that would be almost immune from these sorts of attacks would be a military base.”

The military shootings have been so frequent that there are eerie parallels between some of them. In the 2014 attack at Fort Hood, Specialist Lopez bought his .45-caliber handgun at the same gun shop near the base where Major Hasan bought the weapon he used in 2009. Many of the gunmen have taken their own lives, as the one did in the Pearl Harbor shipyard attack and as Specialist Lopez did.

But the military attacks are as varied as any other mass shootings in the country, with their own motives and circumstances. Some of the suspects, like the one in Friday’s shooting, are not even American service members, an indicator of the wide array of civilians and others who are on military bases at any given moment. The gunman in the attack on Friday was a Saudi national who was a member of the Saudi Air Force and who was on the base for aviation training, officials said.

In some ways, the military shootings reflect the larger issue of mass shootings in America. Just as lawmakers and law enforcement officials struggle to prevent violent attacks in schools, workplaces and places of worship, so has the military had difficulty in identifying threats and acting before it’s too late.

After so many incidents, military officials have now embraced active-shooter preparedness and training, focusing on the issue as much as schools and other workplaces and institutions. One Air Force webpage on active shooters defines the meaning of a “lockdown” and lays out the “actions to consider” before, during and after an incident.

“Take note of the two nearest exits in any facility you visit,” the webpage instructs.

Still, many question whether the military has done enough to ensure that soldiers and sailors are safe while on base. One of the issues involves guns.