In Sweden and Germany you have to have an officially registered address. The government uses this to send important mail to you and keeps it in a registry.
I am pretty confident you can register at an address just because someone has decided you can live with them, like your friend or family member. You do not require a rental contract in that case.
How do you define the boundary between that and a stranger offering to let you register at their address when you don’t live there?
Some Swedish information says “you should register where you sleep the most” and not doing so is illegal.
How enforceable are such laws? Is there a realm of ambiguity where a case could not be brought against one?
For example: if you registered somewhere and didn’t pay rent, if you were there five nights a month, and then spent four days each at different hostels, technically you would meet the description above. Furthermore, even if you didn’t, it would be hard to tell.
But I’m less interested in what you could get away with than what is actually legal. Would a judge say it counts as residing if you were there three weeks of the month? Two, if you said you commute and travel a lot for work? Or even a few weeks per year, if you similarly say you travel for work?