Something pretty close happened in Arvada, Colorado recently. A "good guy with a gun" shot the "bad guy with a gun" who shot a cop. When another cop arrived on the scene, he shot and killed the "good guy with a gun" mistaking him for the "bad guy."
The good guy with a gun died, so criminal charges and defenses became moot. But there was no doubt that the "good guy with a gun" was justified in shooting the bad guy, and the authorities investigating the case determined that the cop who shot the "good guy with a gun" was also justified in his actions.
The shooting happened on June 21 in Olde Town Arvada. Police also
released their timeline of events that can be viewed at the bottom of
this article. According to police, Officer Beesley was dispatched to a
suspicious person call at about 1:30 in the afternoon. When Officer
Beesley was walking in the area of Weber Street, the suspect got a
semi-automatic shotgun and ran after Officer Beesley. Arvada Police
say that when Officer Beesley stopped to turn, he was shot
“immediately” by the suspect. The police timeline then states that the
suspect shot out the windows of the officer’s car, returned to his
truck and grabbed an AR-15. The suspect went back to Olde Town Square
with the AR-15 when he was confronted by the good Samaritan. The good
Samaritan was armed with a handgun and shot the suspect.
Police say that a responding Arvada officer encountered the good
Samaritan ad that the good Samaritan was “holding the suspect’s
AR-15.” That’s when the responding officer shot the good Samaritan.
Another Colorado case in 2016 that attracted international attention involved a shootout between two biker gangs at a motorcycle show. It wasn't possible to determine who was an aggressor and who was firing in self-defense, and so, ultimately, the only prosecutions were for people who had guns that they weren't allowed to legally possess due to prior felonies or prior domestic violence cases.
It is much more common for these situations to be resolved by prosecutors not bringing charges at all than it is for them to be resolved in mutual murder trials where self-defense is asserted in each trial.
Also, in both of these cases, the genuinely most criminally culpable people as far as after the fact investigations could tell, were killed (although there is always a temptation to throw the dead guys under the bus).