This is a fascinatingly deep question, and I'm very tickled that our two touchpoints in it are a transforming robot tank and Batman.
My personal opinion is that ethics and morals are not reflections of some universal truth of Justice and Goodness, as they are often framed, but are instead best-practice guidelines on how to function in the big, messy world without causing undue suffering to yourself and others. A facet of this is determining, case by case, how much you need to prioritize yourself vs how much you can afford to help others - in the framing you've proposed, selfishness vs selflessness.
Taking the specific examples we're focusing on - two cases where someone attempts to prevent a revenge killing for the benefit, not of the victim, but of the avenger - I think they reflect this worldview, that the killing is not seen as some innately universally-judged evil act that must be prevented for its own sake, but that the act of killing will harm the killer in a way the person trying to stop them doesn't want to see.
For Catwoman, committing premeditated murder wouldn't solve any of her problems in any way that arresting Falcone and having him legally unraveled would. It'd just park a first degree murder charge on someone who'd up til this point only dealt with petty larceny, and it would potentially weigh her down with misery and regret as she grappled with the trauma of taking a life.
For Megatron, killing Sentinel Prime wasn't a bad action because he deserved to live. They just spent that whole fight scene tearing through enemies. They're warriors on track to spend the next four million years killing each other; the whole "taking a life" ship has already sailed. The problem is that Sentinel is a symbol and a structural part of the political narrative in the founding of the next stage of Cybertron's society. If the first thing the new regime does is bloodily avenge itself on the face of the old regime for the personal wrongs it did them, that proves that the only thing they care about is personal satisfaction of their individual desires - just like Sentinel. Meet the new boss, same as the old boss. If they can instead take a step back, think of the good of Cybertron as a whole, enforce a rule of law and a fair system of justice that applies equally to everyone, even on someone they personally loathe, that would signify integrity and credibility and the hallmark of wise, just and fair leadership capable of setting aside personal feelings for the greater good. It's not about Sentinel; it's about whether the satisfaction of killing him is worth the price of enforcing forever that personal vendettas are more important than the well-being of the people of Cybertron. Which makes it really obvious which one Megatron is going to pick.
My hottest take, and I mean this very genuinely, is that most of the human perception of what constitutes goodness and justice is one thousand percent based on vibes, and is extremely susceptible to narrative reframing. We see an unsympathetic victim (Sentinel Prime, Falcone) who has gleefully caused suffering to innocent people (so judged because they are framed sympathetically, not because we've actually enumerated their lifelong actions to determine they've never done anything wrong) and we feel (feel) that it would be right and just for them to suffer consequences (emphasis on suffer) because that would balance the scales on this vibes equation and that would make us feel like justice had been served. Would this suffering lead to any material good? Not inherently. Would it heal the victims? Not usually. Would it remove the source of the problem? Categorically not, what with how negative reinforcement works (or rather does not work.) It also wouldn't do anything about the other people empowered by the same system to be just as shitty in just as many ways that just happen to be offscreen from our POV. But it feels fair. So what is justice, if it reduces down to "I want them to hurt for the hurt they've caused me"? If it can be sated with a spectacle or distracted by a long nap and a good joke to let the feeling fade? What purpose does this justice serve if it is devoted wholly to the satiation of a bone-deep chordate-brain hunger for Retributive Violence rather than towards actually ensuring that the lives of those harmed are healed and supported and built up again after being broken down? (This is the entire core character arc in The Batman, btw, I'm not just monologuing for no reason here. He calls himself Vengeance for a reason, and the reason is he's doing Batman wrong)
That feeling - that white-hot burning core of Righteous Fury - is the unexamined heart of many systems of morality that focus, not on doing good, but on exacting satisfying retribution on Bad People Who Deserve It, categorized as People Who I Can Hurt Without Feeling Bad Myself. It's a very tempting concept for people who have suffered at others' hands. That feeling, that powerful instinctual understanding of "that's unfair," is incredibly strong. In my opinion, most systems of ethics are built, not around relitigating what is Good and what is Bad per se, but in trying to shape and curb that bone-deep, unbelievably powerful desire to rend the flesh from the bones of your tormenters.
But I mentioned that feeling is susceptible to narrative reframing. This is, as I understand it, a huge part of lawyering. Tell the story of what happened using true events and adding no falsehoods, but highlight the parts that make it feel like your client is the one who is being treated unfairly. They're not an unsympathetic wrongdoer who you can punish without personal moral stain - they're a loving spouse, a parent of three adorable children, they have a really cute puppy, they donate to charity, they're a wonderful conversationalist, a kind friend, etc etc. All those things can also be true of people who do terrible things, but thinking about them defuses that White Hot Core by making us sympathize with the sympathetic parts of them.
This is incredibly well-understood in fiction. It's the whole reason the tropes Kick The Dog and Pet The Dog exist. When you want the audience to root for a character's destruction, leave aside any of their potential quiet moments of sympathy - their tragic backstory, their cute pet, their adorable relationship with their mom - and instead show them going out of their way to commit some minor act of petty cruelty, say Kicking The Dog. The audience will infer that this badness is 24/7 and they have no reason to curb their enthusiasm for Righteous Vengeance. But if the writer wants the audience to see a spark of good in them, to sympathize, to believe they can be redeemed, they'll highlight one of those small moments of charming kindness, and allow them to Pet The Dog instead.
Neither of these acts, in the grand scale, have any bearing on the morality of this person's actions. A pet dog doesn't counterbalance a razed village; a kicked dog doesn't negate a generous contribution to the local soup kitchen. Goodness and badness is not a linear scale added or subtracted to by opposing deeds. BUT showing them to an audience reframes them narratively, and THAT is what shapes the judgment of the White Hot Burning Core. In the space of fiction, this form of bottom-shelf emotional manipulation is one of the cleanest ways to get the audience to root for the messy destruction of what is ostensibly, in the universe of the fiction, a wholly complex and living person who definitely has reasons for everything they've done, even ones that could be framed sympathetically when shown.
Meanwhile, in the real world, ethics are an attempt to judge what is best in a given situation without trusting the White Hot Burning Core to make the call, no matter how compelling "but it would feel really good though" might seem. They try to give someone perspective, context, other priorities to consider. The White Hot Burning Core might want you to rip someone's arms off for driving slow when you've got important places to be, but Ethics can present a number of compelling reasons not to do that - even if it's just "ripping their arms off will definitely make me even more late." And yes, this can be a balance of Selfishness Vs Selflessness. You are one of the people whose wellbeing ethics is designed to make you prioritize improving even if it feels weird, and when all other things are equal, your own health and happiness can be the deciding factor. In a world with an overarching Moral Force that weighs the goodness of your soul by sifting through every grain of action and intent seeking negativity to punish you for, absolute selflessness to the point of self destruction would still probably be seen as Morally Wrong, simply because the universe is a better place with you in it trying your best.
Anyway, if doing the right thing was simple, easy and painless, we probably wouldn't have so many thousands of years of arguing about what it looks like. Good luck out there everybody 👍