Would the cops arrest the man for vigilantism?
There is a defense of others justification in the criminal codes that expressly justifies this kind of conduct.
Will this go to trial or would he be let loose without needing to call
an attorney? What would realistically happen to this person, legally
He would be let loose, after getting contact information and providing a statement. If the case went to trial, he would be called as a witness. The police would probably release a positive press release and reporters would try to interview him.
Edit: Would anything change if the would-be murderer was a rogue cop
Same result if he was a "rogue cop."
The posse comitatus statute in the U.S. prohibits use of the military for law enforcement. So, a criminal violation of that statute is possible if this was ordered by a commanding officer as part of the soldier's official duties rather than in his capacity as a mere citizen bystander.
But, in a role as a mere citizen bystander a soldier would be let go and highly praised. Don't trust me on that. It has really happened:
An Islamic State operative accused of an attack on a European train
that was stopped by three young vacationers from California went on
trial Monday in France on terrorism charges.
Opening the trial of Ayoub Khazzani, the judge said that the
31-year-old Moroccan, who had ties to a notorious terror mastermind,
intended to “kill all the passengers” aboard the fast
Amsterdam-to-Paris train in 2015 but “lost control of events.” One of
the young men who helped subdue Khazzani told investigators that the
shirtless gunman seemed high on drugs and “completely crazy,” the
The dramatic story of how Khazzani was brought down by the three
American friends was turned into the Hollywood thriller “The 15:17 to
Paris” by Clint Eastwood. Khazzani’s trial is expected to last a
month, with testimony expected from the two U.S. servicemen and their
friend, who were hailed as heroes and granted French citizenship.
Eastwood has also been summoned to appear Nov. 23. It’s unclear
whether the four men will testify in the Paris courtroom or by video.
During the failed August 2015 attack, Khazzani swaggered bare-chested
through the train with an arsenal of weapons. He shot one passenger
before the trio of traveling Americans — Alek Skarlatos, Spencer Stone
and Anthony Sadler — tackled and helped subdue him.
(Los Angeles Times November 16, 2020)
UPDATE: Misunderstood the edit.
First of all, your criminal and civil liability depend upon your intent. If you in good faith believe someone not in uniform to be a criminal, when in fact, the person is an undercover cop or a soldier, the analysis wouldn't change because you wouldn't realize the situation.
Generally speaking, a private citizen does not have the authority to interfere with someone known to be a law enforcement officer acting in the course of their official duties, and is obligated to follow the law enforcement officer's instructions in those circumstances, so the risk of liability is much greater in that situation. Essentially, while you could act lawfully if you knew that the law enforcement officer was acting unlawfully and you were preventing a crime, it would be much, much harder to prove that your actions were justified. The police might arrest you, at least until matters are cleared up. The law enforcement office would argue that he was effecting a lawful arrest, not trying to murder someone, and that you assaulted and falsely imprisoned a law enforcement officer (crimes that carry enhanced sentences), and usually a policeman is going to win a credibility contest over an ordinary citizen at trial when the accounts differ (although the fact that you and the two people you saved would have the same story would help and there might be other context providing a motive for an attempted murder that would help).
The case of a soldier would be easier. A soldier does not generally have the power to pull a gun on someone in the U.S. in peacetime, or to engage in law enforcement, or to direct a civilian to help him (although an activated national guard member would be an exception). So, it would be pretty simple to determine that a soldier, even in uniform, is acting unlawfully, in an unofficial capacity, as a criminal, which would authorize the civilian to act in defense of others. Once the police come, it is likely that the soldier would be remanded to the military and subjected to a court martial rather than to the civilian justice system, so the intervening individual might be called to be a court martial witness rather than a civilian court trial witness. In the case of an activated national guard member during some kind of emergency, however, the issues presented would be similar to those of a civilian rogue law enforcement officer.