If you're poor then you're basically mentally ill.
I couldn't afford anxiety/depression meds and went to a professional. Literally told me, almost verbatim, "I don't think you're a danger to anyone or yourself, but I'm going to put you down as 5150. After a holding period you'll get medicine."
Thought about it, decided no as I didn't want to screw up my background checks just to get medicine.
"Well I already put it down."
I didn't want to fight my way through two guards (though I wish I would have tried) so I had to go through a shitty, depressing, and degrading experience. And I couldn't afford the medicine they prescribed me. The entire point of lying to game the system, the entire point of fucking me while acting like a savior, and I couldn't even get medicine.
So yeah. Tagged as being a danger to myself or others because I didn't have money to buy medicine... and a mental health professional thought she figured out a lifehack and tested it on a real person.
If you're a danger to yourself or others, police can detain you with an APOWW, which stands for Apprehension by a Police Officer Without a Warrant, and hold you until you are deemed safe at an "appropriate" mental health facility. (Most of these places are horrible tbh. Usually filled with the homeless and genuinely mentally ill/unwell people). Back in my EMS days I would dread running calls to these places.
I guess this really depends on where you live. Germany at least has rather strong protections for patients. We had a case last year in our town of a woman with ~40 suicide attempts who would still not be held against her will (German source). So please get help if you feel you need it (and get informed about your rights).