This is not uncommon, that laws are written not considering all nuances, so a generally innocent thing is made illegal.
The primary protection for this is prosecutorial discretion which is to say the DA can choose not to take such cases. Also the police have to be willing to enforce and book instances (they’re usually happy to) and gubernatorial positions like the mayor or governor can command law enforcement not to enforce a specific law (which sometimes they’ll obey).
This often comes up in undocumented immigrant cases in which there are communities with a lot of overstayed visas, or while cannibis was in a grey zone of being locally accepted while nationally scheduled.
It’s also why tweens weren’t gathered up for making a Facebook account while under thirteen years, even though that violated the CFAA, a federal crime punishable by up to 25 years. We don’t really want to put little girls in federal prison.
This is a problem when some official would like you to disappear into the penal system, say because he covets your land or your livestock or your spouse. Then your chastity cage may become a liability.