Pretty much any cop show will have characters deciding this, going against their own bosses, other agencies, ignoring diplomatic rules, etc. so convinced are they that trying to solve a murder justifies doing anything they want. Bones pretty surprisingly made this an Averted Trope when Booth told the team he would not screw the rules to bust a suspect with diplomatic immunity because of the consequences far beyond their murder investigation.
It seems like every episode involves Jack Bauer violating security protocol/administrative policy/ethical behavior/the Geneva Convention in order to "do what has to be done". He rarely pays for his actions.
The same cannot be said of almost anyone else on 24, such as Gen. Brucker, who was arrested and considered a traitor because he defied Presidential orders and surrendered IRK President Hassan to a terrorist cell, saving thousands of innocent people from a dirty bomb attack.
Jack Bauer ended up spending several years in a Chinese camp being tortured, so...he's probably paid for it.
And pretty much anyone he ever cares about dies a violent death or turns out to be a traitor. He also gets fired, arrested, and otherwise punished repeatedly. While he may not always suffer long-term punishments, he surely doesn't gain much.
This gets completely deconstructed in the final season, when Jack is determined to do 'what's right', but ends up causing a holy amount of mayhem and death. Luckily, he listens to reason at the end — before he almost causes another world war.
Agents of S.H.I.E.L.D.: In "T.A.H.I.T.I.", Coulson ignores orders from his superiors, gives Fitz-Simmons a file classified above their clearance level, and tracks down and assaults a SHIELD facility even he isn't supposed to know about, all to save Skye's life.
By the following episode, Coulson's officially hit his breaking point, as he tells Skye to hell with the protocols and rules he used to put so much faith in — he is going to uncover the whole truth behind his resurrection and the secrets kept in the Guest House facility, no matter what.
Both Sinclair and Sheridan are liable to violate commands from Earthforce (usually through Loophole Abuse) to do what they feel is right.
In the episode "Believers", Doctor Franklin disobeys a direct order from Sinclair so he can save a child from a disease that the child's parents won't let him cure for religious reasons. Said parents find out about the surgery and kill their child, believing that the soul has left the body.
As was Sheridan's speech (in the same episode) declaring the station's secession from the Earth Alliance because of Earth's recent atrocities. He basically lays the cards on the table and tells anyone who doesn't want to go along that they would be free to leave, but that Babylon 5 was not playing by Earth's rules anymore.
In defiance of what normally happens with this trope, when Sheridan says that anyone who disagrees with him is free to leave, one guy in the background takes off his headset and walks out the door. Word of God is that was because JMS always thought it was unrealistic that no one would object when a commanding officer defies orders.
It's hard to name a character on the show who doesn't do this at least once. Full credit must go to Garibaldi, however. Screw the Rules, I'm Doing What's Right is practically his personal mantra.
Battlestar Galactica (Reimagined): This is more or less the key trait of Karl "Helo" Agathon from the reboot. He's the guy who always does the right thing, no matter what price he has to pay or how hopeless a situation it puts him into; in the show's pilot he willing dooms himself to die so that an Omnidisciplinary Scientist can have the last seat off a nuked world. And considering just how badly most members of the human fleet compromise their beliefs or abuse their power, there are times when Helo seems to be the only one with a conscience or sanity.
In one memorable case, he disobeyed his commanding officers to prevent genocide... of a race of androids bent on annihilating the human race. YMMV whether this crosses into Honor Before Reason territory.
Lee Adama pulls this in the Season 1 and Season 3 finales.
Has one instance that stands out, though it's slightly less this trope and a little more of a threat to invoke the trope: Alan Shore is defending an old acquaintance accused of murdering her fiancé literally moments before their courthouse wedding. But when it's revealed that the bride switched identities with a close friend years back, and claims that said friend is the real murderer, Alan finds proof that said friend came to the bride a year ago and wanted to go back to her real identity. The bride then killed her, and later murdered her fiancé as well. Alan followed up with this: "The only reason you're not sprawled on the floor under a bailiff with handcuffs is because of attorney-client privilege, and, frankly, I don't need this (case) that much. I've done a lot of talking over the years. I'm tired. I'm rich. Take the (plea bargain, 12 years for manslaughter) or I'll walk through that door. I'll get disbarred. And I'll put you away for life. Double first-degree. It'll be life. Until the end of your life."
Alan Shore does this a lot. When he considers a client to be morally in the right, he has gone so far as to blackmail the opposing party into settlements. He even once pointedly did notadvise a client to flee the country when the case was hopeless, but the cause just.
Buffy the Vampire Slayer: When the Council puts Buffy through a cruel test that involves stripping her of her powers and almost gets her and her mother killed, Giles breaks the Council rules and runs to her assistance. The Council says that while she passed the test, he did not, and fires him.
Outside of her selfish nature Faith is willing to Shoot the Dog and kill Angel in case he goes evil, cover up her accidental murder of a morally grey character, and allow herself to be killed to satisfy Buffy's thirst for vengeance and go against Angel trying to redeem her. Recently, she gets so upset with Angel tormenting himself that she tries to stab him in the back and turn him human so he can let go of the guilt he feels, only stopping because of the Body Horror her actions would cause.
Chuck: The fourth season finale has the eponymous hero going against the CIA in order to get a chance to find a cure for a poisoned Sarah, who was struck down with a virus inflicted on her by the Big Bad.
The BAU are willing to break the rules for each other.
This line is used almost exactly in the episode "Amplification".
Prentiss: Screw protocol, Reid's in trouble!
In the episode "Penelope", Hotch tells the team regarding Garcia getting shot:
Hotch: I don't care about protocol, I don't care whether we're working this officially. We don't touch any new cases until we find out who did this.
Defiance: This is the basis for the backstory of the Defiant Few. During a battle during the Pale Wars, soldiers on both sides saw that collateral damage was putting civilians, especially children, in danger, so they stopped fighting and worked together to save them, telling their superiors where to shove it when ordered to keep fighting. When news of this spread, it eventually led to a ceasefire and the end of the war.
Many events in time are malleable and adjust to compensate for visiting time travellers (which is why the Doctor can, say, safely walk around with Shakespeare and introduce Charles Dickens to aliens without damaging the universe). Fixed Points, however, are moments of history that cannot (or at least must not) be changed, at the risk of unleashing horrible monsters that could kill a lot of people, or else seriously changing the timeline. Every now and then a character (occasionally the Doctor himself) will say "Screw it" and try to change these fixed points anyway. The results are never good, even when the character was making a moral stance, or trying to save someone's life.
Benton is a positive example and pretty much embodies the trope in the classic series — seen most prominently in the episode "Invasion Of The Dinosaurs".
In general, a key part of the Doctor's motivation for doing what he does is his righteous outrage at the rules and regulations the Time Lords lived by, which prevented them from acting to oppose evil, instead being content merely to stand aloof.
Comes back to bite the Eighth Doctor in his earlier Big Finish adventures. Saving Charlotte Pollard from her death makes her a Paradox Person which causes history to start breaking down.
Doogie secretly operates on a desperate young boy's injured dog despite hospital regulations. When caught, he fights back, saying that he was only trying to do something kind and humane (“something I see far too little of around here.”).
Another episode has Doogie giving his 16-year-old girlfriend Wanda a pelvic examination and performing an emergency appendectomy on her, despite the rule that she needed parental consent. Doogie states that because it was a life-threatening situation, “under the same circumstances I’d do it again.”
Emergency!: The pilot, where Gage shuts off the radio and treats Dixie and the original patient, even though the paramedic bill hadn't been passed yet.
ER: Deconstructed with Doug Ross, as while his actions may have been for the greater good, there was no denying that he caused a lot of trouble along the way. This is ultimately his downfall, as his involvement in the Mercy Kill of one of his patients not only seriously jeopardizes the careers of his best friend and girlfriend along with his own, it nearly costs him his relationships with them.
The show is full of this. The most notable examples are Simon rescuing River, and Mal sheltering them. Then again, Mal's crew are smugglers, among other things, so it's not like they were keen on obeying the law in the first place.
This is basically Mal's world view. He doesn't care if it's going to get him killed or if it's against the law, he does what he feels is right.
Mrs. Burgess: My husband makes a distinction between legality and morality.
Mal Reynolds: You know, I've said that myself, on occasion.
Game of Thrones: In the season 3 finale, this is Davos' justification for going against Stannis' wishes by freeing Gendry before Melisandre can sacrifice him.
Dr. House so often breaks the rules and protocols that his Dean of Medicine every year prepares thousands of dollars just in case he does something that would require a lawyer's help.
Subverted Trope after Foreman breaks protocols at a different hospital to save a patient. The patient lives, but Foreman gets fired almost immediately and is blacklisted by pretty much every other hospital apart from Princeton-Plainsboro, to where he's forced to return.
The Body of the Week on one episode was a Serbian war criminal who was spotted by two of his former victims, who murdered him. Benson and Stabler arrange things so that the killers get away with a light prison term. The boss chews them out; Benson explains it as "I think we did the only thing that's going to allow me to sleep tonight."
A later episode has Agent Huang basically kidnap a young drug addict (the villain of the week was his legal guardian and was keeping him drugged up to stop him testifying) to give him a technically illegal treatment to cure his addiction (since the patent on it expired so wasn't profitable for drug companies to get it approved for use in the USA). The villain threatens to report Huang so he'll lose his license Huang reveals he already reported himself and got off with a slap on the wrist.
Benson and Amaro listen to a woman's heartbreaking, near-death confession that she killed her husband's stalker mistress who had been tormenting the family during the woman's final dying days. The detectives, however, later realize she couldn't have been the killer because her illness would have made her too weak to commit the crime. When they then realize the killer is the woman's young teenage daughter who has been through the Trauma Conga Line of watching her mother slowly and painfully die of brain cancer, her father act like a cheating douchebag and her father's mistress publicly humiliate the family... Benson and Amaro quietly agree to accept the mother's confession and close the case.
The Mentalist: Lead character Patrick Jane, the mentalist, is pretty much made of this. Over time, he often persuades members of his team to go along with it as well.
NCIS Too many examples to count as Gibbs and his team practically embody this trope. They routinely break protocol and often break federal and international law as well in order to bring criminals to justice.
The Ur Example for the series being Gibbs murdering the drug czar who had his wife and daughter killed.
NCIS: Los Angeles: Season 3 Finale had G. Callen killing "The Chameleon" for his murders of Agents Roarke and Hunter, as well as several other people, even when he was ordered to surrender him to the Iranian officials in exchange for the American agent that was held hostage. He is promptly arrested by the LAPD afterwards. He also suspected that he had the Iranians transfer the money via American channels specifically to get the Sadistic Choice to force him to go free, a suspicion that was revealed to have been well-founded.
Nikita: In the first season finale, Nikita is captured by the CIA — who believe her to be responsible for the attempted assassination of the CIA's director — and she is only saved when her ally, CIA agent Ryan Fletcher, takes a serious level in badass and holds the director of the CIA at gunpoint, despite knowing he'll be sent to prison for it (possibly for life).
Pan Am: Has Colette bringing the Haitian refugee on board despite regulations, and Kate helping her fellow courier escape Berlin despite orders to the contrary.
The Practice: The firm represented a client in a hit-and-run accident. The client's doctor discovered on the plaintiff's medical charts that he had an aneurysm (which his own doctors missed) that would kill him if it wasn't treated. The client refuses to allow the firm to disclose this information. Jimmy Berluti defies attorney-client privilege to tell the boy and his mother of his condition, enabling the doctors to save his life and earning Jimmy a minor judicial censure.
Princess Returning Pearl is full of this trope. Basically it shapes practically all the "illegal" things that the main characters do.
Psych: Shawn tries this trope when Juliet finds out he's been lying about being a psychic. Jules is not impressed.
Shawn: I put away, like, over a hundred criminals. Most of them were murderers. I'm good at what I do, and what I do is good...isn't it?
Revolution: In The Stand, Jason Neville decides not to call in the air strike on the rebels and even warns Charlie about the air strike occurring in 12 hours.
Detective Maggie Sawyer:*referring to a diplomat's son who Clark and Lois have caught committing murder as well as trafficking crimes* As a consular guest in our country, I'm afraid Mr. Lyons can't be convicted of any crime he commits on our soil. Not even murder. I'm sorry, I can't touch him.
Lois:Well I can. *kicks him in the groin* (later on, Clark and friends happily find a legal loophole that allows them to bring him to justice)
In the first season episode "Enigma", Daniel Jackson goes against orders to help the Tollan get to their stargateless new world. One should note that he got away with it because A) he's a civilian, so he's not subject to military law, and it would be hard to find a civilian law to cover the matter, and B) his superiors (chiefly O'Neill and Hammond) agreed with the decision.
In the first season finale "Within the Serpent's Grasp", the whole of SG-1 disobeys orders to launch a first strike against Apophis and his assault upon the planet after the Obstructive Bureaucrat and Corrupt BureaucratSenator Robert Kinsey shuts down Stargate Command. They get away with this because Kinsey very nearly doomed the human race and they saved the planet.
In the Ori arc, three ascended ancients are shown to do this to help humanity. One loses his memory and mind, one dies, and one decides to Sealed Evil in a Duel.
In fact, the entire series starts with Jack having to explain his use of this trope in the Movie. Not only did he lie about nuking the Stargate when there turned out to be a threat, which would have wiped out the indigenous civilization (he took the threat itself out with the bomb instead), he lied about Daniel Jackson being dead so Daniel could stay with the wife he'd fallen in love with. General Hammond was not terribly pleased with the two of them when he found out the deception, but he got over it quickly enough.
Star Trek: Deep Space Nine: In "Time's Orphan", security guards stop Miles and Keiko O'Brien from stealing a Runabout in a desperate bid to save their daughter Molly. Odo waves the guards aside, comments that O'Brien should have done a better job of sneaking onto the hangar, and allows them to take the Runabout.
Star Trek: Enterprise: In "Cogenitor," Trip disobeys the Captain and befriends an alien belonging to that race's mistreated minority, a third gender. He shows her things she's never seen before, but eventually the Enterprise has to leave, and the alien commits suicide.
Episode "Suspicions" does this twice for Dr. Crusher. The first time, against the wishes of the family, she performs an autopsy on a scientist who she believes died due to foul play. In a subversion, the autopsy turns up nothing suspect and she's relieved of her position. Played straight the second time, when she steals a shuttlecraft and flies into a star to confirm her suspicions.
"The Wounded" features a Knight Templar version: Captain Maxwell believes the Cardassians are preparing for war, but Starfleet won't listen, so he goes rogue and starts destroying ostensibly peaceful (and definitely defenseless) Cardassian ships and outposts. Turns out he wasn't completely bonkers, but he was definitely jumping the gun and gets hit hard for it.
Subversion: Another episode finds Data in temporary command of another starship as part of a scratch fleet seeking evidence that the Romulans are violating the Neutral Zone, and goes against Captain Picard's orders in order to achieve the mission objective. When subsequently debriefed, he offers his apologies, whereupon Captain Picard points out that a Starfleet captain is not only authorised but expected to countermand orders if they have reason to believe the safety of their ship demands it, though presumably they would need a very compelling explanation when they got back to port, which Data had in spades. (Actually Truth in Television for many navies.)
In "The Pegasus", Picard mentions he picked Riker as his first officer because of an incident where Riker didn't allow one of his previous captains to beam down. Picard was impressed by Riker challenging a captain's authority for the safety of the captain and the ship's crew.
Nikolai Rozhenko in "Homeward" abducts a village from a pre-warp planet to ensure someone survives a coming disaster, bypassing the Prime Directive. Most other Prime Directive-related episodes discuss it; "Pen Pals", for example, has Picard and Worf support the Directive in the case of a doomed planet, with Geordi and Dr Pulaski aghast at the idea and supporting intervention, until eventually Data finds a loophole that lets them save the planet.
Episode "Amok Time". Kirk violates Starfleet orders by returning Spock to Vulcan to save his life.
Episode "Balance of Terror". Kirk violates "inviolable" Starfleet orders not to enter the Romulan Neutral Zone because he feels the invading ship must be destroyed to avert a war.
Episode "The Menagerie", Spock risks the death penalty to return Captain Pike to Talos IV.
Pretty much any time the Prime Directive is mentioned in an episode, Kirk will wind up going against it to save the ship or the planet.
Averted in "Wolf In the Fold", when Kirk explicitly refuses the suggestion that he help Scotty escape the planet on which he had been charged with murder. While he does his best to, and eventually does, get Scotty cleared of murder, Kirk says that he'll allow Scotty to be jailed and executed if he's found guilty even if Kirk believes him innocent. Why? Because the planet is a strategically vital port, and helping Scotty escape its justice would sour them against the Federation.
Star Trek: Voyager: In "Thirty Days", Tom Paris screws the Prime Directive to try to save an ocean planet that was slowly being destroyed by an oxygen mining operation. He gets a demotion and thirty days in the brig for his effort. And he didn't even save the planet.
Castiel does this. Angels aren't supposed to defy their superiors, but he ends up hunted and losing his abilities because he decides to help Sam and Dean send Lucifer back to Hell. The other angels want Lucifer to destroy the world because they want Paradise.
This is arguably a major theme of the entire series—Sam and Dean's entire job entails a considerable about of criminal behavior, but it's all in the service of saving the world.
Titus: The final episode sees Amy confronted by the man who sexually assaulted her when she was younger. After finding out who he is, Titus and company have the molester cornered in a school bathroom, ready to wail on him with a baseball bat. The school principal, who up until this point has been nothing but an Obstructive Bureaucrat, says he has to call school security, but tells Titus to "call me when I'm done."
White Collar: Neal does this frequently. If doing what he knows is right means breaking a few rules, he's all for it.
The Wire: One of the defining characteristics of Jimmy McNulty. Also shown with Bunny Colvin and Lester Freamon. They all pay for it.