This is deliberately left ambiguous, possibly so further details of Mary's past can be explored in further episodes.
There is no stated explanation for this: the elaborate plan (months in the making) Sherlock has devised to gain access to Magnussen's apartment is not recounted to in order to highlight the level of security involved, but as a 'bait-and-switch' plot device to deliver an unexpected payoff when we find an Assassin in the apartment, and the identity of this Assassin to be Mary. 'Claire De La Lune' is exactly the same device being executed in another manner.
It's just a very attentive, preemptive writing technique that anticipates viewer response to clues (and importantly doesn't condescend to them) and then reveals it to be misdirection. This is the legacy of meta-cinematography, finally finding itself in television.
Sherlock has already made it very clear that it doesn't necessarily believe in hand-holding the audience through individual plot details, as demonstrated by the still not fully resolved Reichenbach Fall.
It leaves people to speculate, but never resolves fully: It's part of its charm. It will likely never be disclosed, but it won't stop people from enjoying speculating on here!
They're goading us with something we don't have the pieces to resolve, and paying lip service to our need as an audience to know every detail by removing the opportunity to do so.
This is quite funnily appropriate for this site: They're turning us all into Andersons