Legal guardian
If someone (like a person's doctor, psychiatrist, or family member) thinks that a person is incompetent, they may ask a court to choose a legal guardian.  In the United States, the court must hold a hearing to decide whether the person needs a guardian.  The person must be given a lawyer, and the court must listen to arguments from both sides.  If the court decides that the person needs a guardian, the court will choose one.  That guardian may be a family member, a friend, or a stranger.