Listen carefully to what Mary says: “people like Magnussen should be killed, that’s why there are people like me”. She’s the type of person who kills people like Magnussen. And what type of person is Magnussen? According to Sherlock he is ‘the Napoleon of blackmail' who runs the Western world from Appledore, using the “greatest respository of sensitive and dangerous information anywhere in the world”. And as long as Magnussen has that information “the personal freedom of anyone you have ever met is a fantasy”. He’s not a very nice person, in fact, he’s a pretty nasty guy who turns Sherlock’s stomach. When Magnussen flicks John’s face at Appledore he tells him “I know who Mary hurt and killed. I know where to find people who hate her. I know where they live. I know their phone numbers. I could phone them right now and tear your whole life down.” He could set these people on Mary, and they obviously wouldn’t call the authorities to have her arrested and properly tried in a court of law. They would hunt her down and kill her. Probably not very nicely, because they are not-very-nice people. So Mary may be right, people like Magnussen should be killed; that’s why there are people like her.
Who else has killed someone?
and then justified it as the killing of a not-very-nice person who deserved to die?
Remember that when John shot the cabbie Sherlock was voluntarily taking the pill - he wasn’t being coerced. This means that John cannot avail himself of the “defense of other” defense to murder (akin to self-defense except that the homicide is committed to defend the life of another person, not yourself). Sherlock confirms this when he tells John that he wasn’t really going to take the pill (true, John doesn’t believe this, but he does acknowledge that Sherlock was voluntarily risking his life to prove he was clever, because that’s how he gets his ‘kicks’). John actually committed murder that night and then threw the murder weapon in the Thames. Nevertheless, we love it when they giggle at the crime scene and then go off to dinner together.
Also remember that after John shoots the cabbie Sherlock tortures him to force him to reveal Moriarty’s name telling him “you’re dying, but there’s still time to hurt you”.
Finally, remember who actually does kill Magnussen:
So don’t be too judgmental of Mary. Both John and Sherlock have committed murder to save each other. I don’t hear anybody criticizing them for doing this - in fact they are praised for doing so. So why the double-standard when it comes to Mary? Is it because we don’t know her back-story? Sherlock has deduced that Mary was an intelligence agent, but he does not know what country she was serving. By her blonde hair I suppose we are to assume she is Russian, but that could be a red herring. Sherlock trusts her, maybe, because, like him, she is on the ‘side of the angels’, even if she isn’t one herself.
The fandom shouldn’t complain when John Watson’s wife turns out to be an assassin, because if the fandom likes Sherlock Holmes, and the fandom likes John Watson, then it is, indeed, what the fandom likes.