I've been voluntary every time but two times a crisis worker told me that if I didn't go voluntarily they'd get a 72 hour hold on me and go to court to get an order from a judge. That was in the emergency room.
While in one psych ward I said I wanted to go home after two days during one of those times and the social worker said they'd get a 72 hour hold and go to court to involuntarily detain me. But that didn't happen because I stayed and later my suicidal feelings and plan went away. Each time I was told about the 72 hour hold and the court, if I didn't go voluntarily it was because I had a plan of suicide.
Where I live there aren't a lot of circumstances where they can involuntarily detain someone. Mostly it's when someone attempts suicide threatens suicide or has a plan of suicide, attacks someone or threatens to attack someone.