You do whatever you want and then confess, and then everything is ok. For those who believe in religion, no doubt confession is a consolation. And even for those who don't, it's comforting. We're taught from an early age that concealment increases our guilt, that confession will mitigate it. The requirement to confess is linked, I think, to the development of our whole modern notion of the individual person, that person's interiority, character, responsibilities.
People are eager to confess.
In this sense, our modern culture of confessions develops from Rousseau and the Romantics, who first claimed that they had to expose their souls in order for us to know them fully. Our whole notion of character values honesty and sincerity very much. It's just because confession is such an intimate and volatile kind of act and speech that one needs to protect it and handle it with care. Lots of people writing in asking if they should confess about one thing or another. Everything depends on the situation.