This was not inevitable. At the risk of oversimplifying a dynamic problem affecting a highly skilled force, the SEAL crisis breaks down into three components: leadership failure, an endless war, and the drive by both previous SEAL admirals and retired operators to profit from the SEAL brand, which has become a highly sought-after financial and cultural commodity.

Over the last 20 years, the SEALs have moved further from accountability as a result of their battlefield exploits, which have been publicized and lionized by three successive presidents. There was no single moment when the community was cast adrift, but rather a steady string of incidents during deployments in Afghanistan, Iraq, and elsewhere. SEAL units, and especially SEAL Team 6, became the war on terror’s entire strategy instead of being deployed as an elite unit in rare and specialized cases. Especially in the aftermath of the 2011 SEAL Team 6 mission in which Osama bin Laden was killed, the men who did the killing became the shiny object civilian leaders flashed to distract us from the government’s lack of any strategy beyond waging more war and killing more people.

The sordid tale of Trump’s repeated Twitter interventions on Gallagher’s behalf is both an affront to the rule of law and tragically ironic. The firing of Navy Secretary Richard Spencer last month over the SEAL command’s efforts to pull Gallagher’s Trident pin, the symbol of the SEALs, may be the final chapter in the “ Free Eddie ” saga. But the Pentagon, Congress, and the American public are now catching on to the fact that the Navy SEALs’ most closely guarded secrets are not their clandestine missions and classified gear but the leadership failures and cover-ups that are endemic to their organization.

So Green issued a letter and a directive to all Navy SEALs this summer. “We have a problem,” he wrote, adding that a “portion” of SEALs were “ethically misaligned.” With that, Green took the first step to correcting a problem that had been building for years: He publicly acknowledged it. No admiral before him had had the courage to do so.

After the verdict, senior Navy officials demanded that Green clean up the SEAL command, which had been getting bad press for the Gallagher case as well as a string of criminal allegations against other deployed SEALs, including murder, drug use, and sexual assault. An entire SEAL platoon was sent home from a deployment in Iraq for heavy drinking.

In July, Gallagher was acquitted of murder, convicted of posing with the ISIS fighter’s corpse, and sentenced to a reduction in rank and time served. Trump congratulated him on Twitter.

During Gallagher’s court martial, witness testimony and evidence made clear that the veteran SEAL, who had eight combat deployments and was the chief of his platoon, had gone to Iraq hoping to get a “knife kill.” The main question during the military trial was whether Gallagher’s stabbing killed the detainee, who was already suffering from internal injuries from a U.S. military rocket attack when he sustained the knife wound.

Gallagher, a sniper and medic, was accused of stabbing an injured and unarmed ISIS detainee who may have been as young as 14 during a deployment in Mosul, Iraq, in 2017. The case had made headlines internationally, and Gallagher had won prominent support from President Donald Trump and Fox News.

Rear Admiral Collin Green had a problem. Green, a Navy SEAL and commander of Naval Special Warfare, knew that his community — 3,000 active duty SEALs, their families, and the several thousand former and retired SEALs who make up their elite military tribe — was locked in a culture war over one notorious SEAL. What could he do about Eddie Gallagher?

First, there has been a genuine leadership failure in both the officer corps and the senior enlisted ranks, where accountability and justice have steadily eroded since the post-9/11 wars began. In an effort to be liked, respected, and admired, officers commissioned by the president to uphold good order and discipline have abdicated their responsibility to seasoned enlisted operators who have far more tactical experience on the battlefield.

That happened during Gallagher’s 2017 deployment to Mosul. SEALs in Gallagher’s platoon reported concerns about him, including allegations that he shot unarmed Iraqi civilians, to their platoon commander, Lieutenant Jacob Portier, but the reports went nowhere. Gallagher, who had been Portier’s main instructor at Basic Underwater Demolition/SEALs training, frequently berated the lieutenant in front of the platoon, according to a SEAL on the deployment. The SEALs were asking a young officer on his first combat deployment to stand up to his former instructor, who had an outsized reputation as a “super SEAL.”

Second, Navy SEALs make up a significant proportion of the special operations community fighting the country’s forever wars. The war in Iraq is over and the war in Afghanistan may be nearing its end, at least for U.S. forces, but SEALs are still fighting around the world. Most enlisted SEALs spend their careers exclusively in special operations and rarely experience the military away from their insular world and its self-reinforcing values.

As a result, their killing skills are finely honed, but the historically unprecedented combat exposure of the post-9/11 years has taken physical and emotional tolls that SEAL leaders are just starting to understand. Gallagher was at the center of at least three problematic incidents during his seven previous combat deployments, which, according to a retired SEAL familiar with his record, are now viewed by SEAL leaders as “red flags.”

One of those incidents involved 2010 deployment to Afghanistan during which Gallagher was accused of killing a child. Gallagher shot at a Taliban fighter who was holding a girl in his arms as a human shield, killing both the child and the militant, the San Diego Union-Tribune reported. Gallagher’s lawyer, Timothy Parlatore, told the paper that Gallagher “felt remorse,” adding: “He tried to take a head shot; it went low.” Gallagher was investigated and cleared of wrongdoing in connection with the shooting, according to the Union-Tribune.

But two SEALs with direct knowledge say that Gallagher continued to revel in the story and retell it, using it to promote his image as a tough, battle-hardened SEAL. One of those SEALs told The Intercept that when Gallagher was a BUD/S instructor, another instructor who had served with Gallagher in Afghanistan told a group of trainees about the operation in which the girl was killed. He described a Taliban fighter or other militant who used his small children, including a baby, as human shields in an effort to avoid a U.S. attack. The instructor described two SEAL snipers in his platoon setting up for a shot on a day when the target cradled a very small child against his chest. One of the snipers was a young SEAL, new to the platoon, the instructor said. The new SEAL refused to shoot the target while he held the child. But the second sniper was willing and fired through child to hit the target, killing them both. The instructor derided the young SEAL and told the class, “Thank God we had a real Team guy,” willing to shoot the child. Gallagher subsequently confirmed that he had been the shooter, telling his trainees, “I got him.”

Later, Gallagher told the story again to his new platoon in SEAL Team 7, adding that he shot the very young girl in the skull because “you have to break a few eggs to make an omelet,” according to a SEAL who heard Gallagher tell the story. In hindsight, each “red flag” should have been an indication that Gallagher needed to be disciplined or removed from his leadership position in the platoon.

Shortly after Alpha Platoon arrived in Mosul in 2017, it became clear that Gallagher was troubled. “He’d wake us up in the middle of the night screaming from night terrors,” said the SEAL who served with Gallagher in Iraq. It was well known within the platoon that Gallagher consumed a cocktail of anabolic steroids, painkillers, and uppers during the deployment. Navy investigators later seized steroids and prescription painkiller Tramadol in a search of Gallagher’s home, as well as other evidence of drug use.

Gallagher also suffered a traumatic brain injury, or TBI — a result of being blown up during another deployment, according to a current SEAL officer familiar with Gallagher’s medical status. At his court martial, witnesses and text messages portrayed a grizzled veteran who lusted for combat. When he deployed to Iraq in 2017, he brought along a customized short blade knife made by a former SEAL teammate. And when an opportunity arose — a badly injured young ISIS fighter who had been captured by Iraqi government forces — Gallagher told his team, “Nobody touch him, he’s all mine.” Two witnesses at his court martial testified they saw Gallagher then stab the captive in the neck at least once (two other witnesses said Gallagher did not stab the militant).

Investigators obtained a text message Gallagher sent a friend after the deployment, with a picture of the dead detainee, that said, “Good story behind this. I got him with my hunting knife.”

Parlatore called the text an attempt at dark humor, the Associated Press reported.

Finally, the unwinding of the SEALs has been driven by old-fashioned brand loyalty at the expense of the health and stability of the force. That the SEALs are a commodity is evident in a network television show (“SEAL Team” on CBS), Hollywood’s highest-grossing war film (the Clint Eastwood-directed “American Sniper”), bestselling books of embellished or disputed accounts of operations (“Lone Survivor”), and even more books about so-called leadership based on SEAL creeds. Gallagher and his wife are currently searching for a ghostwriter to shop a book of their own, according to person familiar with the effort.

The fame and monetary success of a few former SEALs has helped build a public myth about the heroism, sacrifice, and overall greatness of the force, whose members often believe the distorted version of reality with greater fervor than the American public. The result, as one member of the SEAL community told me recently, was that many who want to speak out about corruption inside the SEAL ranks are admonished to keep quiet and “protect the brand.”

SEAL operators rely on their “brothers.” Over time, they’ve built a culture in which the primary goal is protecting the man standing next to them. It’s a culture that elevates loyalty to fellow SEALs over all other concerns, such as the need for justice and accountability when SEALs commit crimes.

Trump’s intervention in Gallagher’s case interrupted a rare moment when a SEAL’s peers wanted to mete out discipline for dishonorable acts. When Gallagher was set to retire two weeks ago, Adm. Collin Green saw a chance to restore “good order and discipline” to his force. He needed to demonstrate that the SEALs were capable of calling one of their own to account.

Although Gallagher was the only member of SEAL Team 7 to be tried and convicted for posing with the dead ISIS fighter, several other SEALs also posed with the body. Green determined that those who held a position of rank or responsibility, including Gallagher, would go before a review board of senior enlisted SEALs in a Navy justice process similar to a civil trial, and be judged as to whether they deserved to keep their Tridents. If the board deemed their conduct unworthy of the SEAL identity, all would be stripped of their Tridents and removed from Naval Special Warfare. The measure would allow Green to send a message that Gallagher’s conduct was beneath the Navy SEALs.

“Collin was trying to let the senior enlisted take ownership over Eddie,” said the retired Navy SEAL familiar with plans for the review board. “All he was doing was following a standard military process until the president stopped him midstream.”

Instead of accountability, the elite military unit got the same message from Trump that their leaders had been sending for the last two decades: You’re above the law.