I'm not an expert on who the homeless are, but my understanding is a significant number have mental illness like my mother did. Mom would make a disturbance like many schizophrenics do, someone call the police, they would recognize her as mentally ill and take her to the psych ward of some hospital. By California law, the hospital has 72 hours to treat them and if they are not deemed a threat, they have to be let go if they want to be.
I'm guessing my mom went through that cycle 40 times. And since they don't have medical care, they have to go to the emergency room even for chronic illness like diabetes. It's a hard situation.