The problem is that the rest of the world doesn't want to - not can't, but finds it inconvenient - to deal with the ramifications of supervising or caring for people in public, strangers, who can't help themselves.
It's much easier to detain inconvenient people than change the rest of the world around them such that it wants to share the burden of caring for them.
Even if not aggressive, they will just "get lost" and try to drive or "go for a walk" in the middle of the night in their pyjamas. I suppose from the way you phrased it that in your case it was mostly harmless and you just disliked getting weird looks, but a lot of dementia patients are actually incompatible with society and need to be detained or given anti-anxiety medications.