I see them operating much the same way that morality clauses for Catholic school teachers do. If you become a Catholic school teacher you are, in many dioceses, expected to uphold some basic standards of morality, avoiding fornication, adultery, divorce, etc. This is because you have the immediate care of younger souls and it’s expected that you won’t scandalize them by your life.
This doesn’t mean Vatican ninjas dispatched from the chancery will bust down your doors in the middle of the night and ransack your house looking for birth control pills. The contracts are typically enforced after the fact, i.e., when scandal has already erupted, such as when an unmarried teacher suddenly becomes pregnant or starts shacking up with her boyfriend, etc. They exist, in other words, both to provide a deterrent against scandalous behavior and to minimize scandalize when it erupts.
In a similar way, ideally, anti-sodomy laws would be enforced only against people who behave in an indiscrete and scandalous fashion. In other words, if you wanted to avoid running afoul of anti-sodomy laws and genuinely couldn’t bring yourself to repent of sodomy, the solution would be not to be caught in the act of sodomy, i.e., to take precautions so that you are not discovered. This is literally just as good, from a “common good” perspective, as sodomy not existing at all, since in either case the risk of scandal is 0.
The demand that a law be rigorously enforced to the max or else be discarded is not and has never been consistent with Catholic moral teaching re: the common good and the duty of the state. It is the state’s responsibility to enact justice when an evil is done, where justice can be enacted in a way that does not conflict with the common good and is proportionate to the evil and so on, not to anticipate and prevent every possible evil regardless of the costs.