The average layman has an incredibly naive understanding of the legal system. Police should have to learn all the laws? My guys, even lawyers aren't expected to learn all the laws by heart, the American legal code is insanely complicated.
Law school teaches the interpretation and implementation of the legal code, it's largely irrelevant to the role of police as law enforcement. Police go to the police academy to learn skills that are relevant to their role as the logistical apparatus that enacts the decisions of the legal system.
Similarly, nurses don't have to go to medical school or learn the biological details about various medical conditions. Instead, they go to nursing school and focus more on practical skills that they utilize to support and enact the decisions of the doctor.
Construction workers don't have to go to architecture or engineering school π
And so on.
I don't think any government is giving homeless addicts cash to pay their rent, that would be insane.
What happens is that the addicts can get the money either from some other government program, or simply by begging, depositing cans, etc. The shelters don't allow people to use drugs inside and they have a curfew. Otherwise, they would quickly become dilapidated drug dens.
Therefore, some addicts prefer to sleep on the street whenever they can afford heroin, and return to the shelter when they can't.