What Jesus taught in the Sermon on the Mount and in other places was how Christians were to behave with each other and in the world in general. Paul elaborated on this in Romans 13. They only time that Christians are allowed to disobey the laws of the land is when those laws stand in opposition to Jesus' commands.
And the scribes and Pharisees brought unto him a woman taken in adultery; and when they had set her in the midst. They say unto him, Master, this woman was taken in adultery, in the very act. Now Moses in the law commanded us, that such should be stoned: but what sayest thou? This they said, tempting him, that they might have to accuse him. But Jesus stooped down, and with his finger wrote on the ground, as though he heard them not. So when they continued asking him, he lifted up himself, and said unto them,
He that is without sin among you, let him first cast a stone at her.
When Jesus had lifted up himself, and saw none but the woman, he said unto her,
Woman, where are those thine accusers? hath no man condemned thee? She said, No man, Lord. And Jesus said unto her,
Neither do I condemn thee: go, and sin no more.He who is without sin among you. He said this according to the custom of the Law; for God commanded that the witnesses should, with their own hands, put malefactors to death, according to the sentence which had been pronounced on them; that greater caution might be used in bearing testimony, (Deuteronomy 17:7.) There are many who proceed rashly to overwhelm their brother by perjury, because they do not think that they inflict a deadly wound by their tongue. And this very argument, had weight with those slanderers, desperate as they were; for no sooner do they obtain a sight of it, than they lay aside those fierce passions with which they were swelled when they came. Yet there is this difference between the injunction of the Law and the words of Christ, that in the Law God merely enjoined that they should not condemn a man with the tongue, unless they were permitted to put him to death with their own hands; but here Christ demands from the witnesses perfect innocence, so that no man ought to accuse another of crime, unless he be pure, and free from every fault. Now what he said, at that time, to a few persons, we ought to view as spoken to all, that whoever accuses another, ought to impose on himself a law of innocence; otherwise, we do not pursue wicked actions, but rather are hostile to the persons of men.
In this way, however, Christ appears to take out of the world all judicial decisions, so that no man shall dare to say that he has a right to punish crimes. For shall a single judge be found, who is not conscious of having something that is wrong? Shall a single witness be produced who is not chargeable with some fault? He appears, therefore, to forbid all witnesses to give public testimony, and all judges to occupy the judgment-seat. I:reply: this is not an absolute and unlimited prohibition, by which Christ forbids sinners to do their duty in correcting the sins of others; but by this word he only reproves hypocrites, who mildly flatter themselves and their vices, but are excessively severe, and even act the part of felons, in censuring others. No man, therefore, shall be prevented by his own sins from correcting the sins of others, and even from punishing them, when it may be found necessary, provided that both in himself and in others he hate what ought to be condemned; and in addition to all this, every man ought to begin by interrogating his own conscience, and by acting both as witness and judge against himself, before he come to others. In this manner shall we, without hating men, make war with sins.
Go, and sin no more. Hence we infer what is the design of the grace of Christ. It is, that the sinner, being reconciled to God, may honor the Author of his salvation by a good and holy life. In short, by the same word of God, when forgiveness is offered to us, we are likewise called to repentance. Besides, though this exhortation looks forward to the future, still it humbles sinners by recalling to remembrance their past life.