Jesus was under the old covenant law, as were the people to whom he was speaking.
Jesus obeyed the law in this matter.
Jesus taught by his own example. Jesus didn't stop the men from stoning the Magdalene for adultery because it was against the law. Jesus stopped the men from stoning the Magdalene for the very reason he said; let he who is without sin cast the first stone.
Jesus was showing those men that while they thought to prosecute the OT law of Moses, they themselves were not pure. Therefore, they were not entitled to stone someone for their sins when they themselves were guilty of sins. As the men recognized of themselves because they then dropped their rocks and departed.
And Jesus, telling Mary to go and sin no more, was showing mercy, forgiveness, repentance and salvation, at his hand, by his decree to her.
Just as was his mission on earth accomplished during his walk on this earth and ultimately upon the cross.
Jesus demonstrated himself to be the word of the new covenant by uttering his challenge to those men who thought to enforce the tenets of the old against the Magdalene.