In the Law, Moses commanded us to kill women who commit adultery by throwing stones at them. But what do you say?”
“Don’t think that I’ve come to set aside what’s written in the Law and the Prophets. I haven’t come to do that, but to fulfill what’s written.
He thought that Mary hadn’t been faithful to him. He wanted to follow the law of Moses and didn't want to put her to shame in public. So he planned to break up with her quietly.
and they said to Jesus, “Teacher, this woman was caught sleeping with a man who wasn’t her husband.