As Jesus said in Mark 2:27, "The Sabbath was made for man, not man for the Sabbath." I don't see why it was wrong for the man to gather sticks, but it was okay for David, who "...entered the house of God and took and ate the bread of the Presence" on the Sabbath Day," (as Jesus says in Luke 6:3). Also, Jesus explains in Luke 6:6-11 that it is not wrong to do good on Sabbath.
ESV - 35 And the Lord said to Moses, "The man shall be put to death; all the congregation shall stone him with stones outside the camp.
For follow-up discussion and general commentary on the topic. Comments are sorted chronologically.
None of these answers addresses the high handed violation of the ten commandments committed by the woman. We know that all good things come from God and that He satisfies all needs. Adultery isn't a need but a listed sin. I feel this is an example of Gods mercy to we sinful people.
In the case of the woman involved in adultery, It was not just the adulteress who should have been put to death, but the adulterer as well (Lev 20:20). Yet they only brought the woman out to be stoned - even though she had been caught in the act, so the man was definitely known!
While the story might not be scripture [see https://ebible.com/questions/13816-does-john-7-53-8-11-belong-in-the-bible], the incident is is keeping with Jesus' ministry.
This incident is similar to His teaching in Matt 7:4-5 and Matt 5:28. These people were applying the law only partially (trying to stone the woman only), and without regard to the sins of their own hearts. Their understanding of the law was corrupt.
[I also think it was the job of the Sanhedrin to sentence to death, not the mob - so this would have been like a mob hanging a horse thief without trial.]
While Jesus was merciful, I think His point was that we are all lawbreakers, so should be careful how we form or implement judgement, lest God judge us.
"You, therefore, have no excuse, you who pass judgment on someone else, for at whatever point you judge another, you are condemning yourself, because you who pass judgment do the same things." Rom 2:1-2
For example, we know adultery is a sin. but so is lust. Do we condemn others for adultery while simultaneously reading dirty books or watching TV shows with adultery and nudity? We are to first examine our own sin and confess it.