I think that it is mostly, if not always, wrong to say that the end justifies the means; what is more apt is to say that the means justify the end.
The end they got was a child.
The means was ‘in vitro fertilisation,’ (or adoption, or sex).
The end justified the means. That’s okay.
But a conclusion doesn’t live for its premises: it would not exist if they didn’t at first exist, because Premises define the possibility of the conclusion through a sound argument.
So, actually, it was the means that justified (led to) the child.
The end she wanted, and got, was marriage.
The means included a deception-cum-betrayal.
If the end justified the means, it would place focus on the nature and characteristics of the end. Therefore saying that that end justified the means would be unsound because the road to marriage, ideally, assumes certain truths and trust.
If the means justified the end, that would be sound because it is not about what marriage assumes, but the path that successfully led to it, questions of morality aside.
An end may have many means, thus a many-to-one mapping; a surjection. There are many ways to weave a basket or express appreciation. One way might be unsound. Regardless, the way that you chose led to the destination that you reached; the end you justified. This is the better perspective.
If we wanted a direct cause-effect relationship. We’d be wrong to think that the end justified the means where there is a many-to-one mapping. An injection, a one-to-one mapping, is more reasonable. And it says that the means justify the end.
So if one justifies his means by his end, he is likely looking from the wrong side of the binoculars. And the one who justifies his end by his means? He follows natural law.