US Physician here. The efforts I place into keeping a patient with capacity in the hospital vary directly to the concern I have about their pathology. There is a very real subset of people who have capacity, i.e. have the mental faculties about them that I cannot legally or ethically place them under a medical hold for treatment, who clearly do not comprehend the gravity of their situation or the likelihood they will die if they leave. I have unfortunately seen a number of patients who require significant amounts of supplemental oxygen, IV medications to support their blood pressure, life-threatening infections requiring IV antibiotics, etc, who for whatever reason decide they don't want to be in the hospital anymore. Discontinuation of this life support puts their life at near-immediate risk, but the folks that are usually trying to leave in these situations are angry, distrusting of the medical system, and very goal-oriented on what they want to leave the hospital for (food because they're NPO, illicit substance use, smoking, care for their dog, etc) to the point that they're capable of saying "yeah yeah I can die whatever fucker, unhook me and let me leave." These patients deserve for me to sit down with them and try and have a conversation about what we can do to keep them in the hospital because I'm worried they physically won't make it through the hospital doors before they lose consciousness.
There are also people who have capacity, want to leave for whatever reason, and aren't literally gonna die in 5 minutes. They get papers and a pat on the back as they walk out the door.
All of this hinges on a patient's decision making capacity, and the reason every single time you want to leave the hospital against medical advice (AMA) you have to talk to one of the treating doctors is they have to determine if you have capacity at the time you're making that decision. To be allowed to leave the hospital AMA you have to be able to demonstrate that you can understand why you're in the hospital, the risks of leaving the hospital AMA, and hold consistent and logical (not necessarily rational) positions on decisions/priorities. If you can't do any one of those things, you by definition don't have medical decision making capacity, and I am not only legally allowed to, but I'm ethically obligated to keep you in the hospital to be treated until either a surrogate decision maker with capacity can be identified OR you have return of your capacity after your illness improves and we have this conversation again.