Every State in the union has some form of involuntary mental health hold. Regardless of whether or not the patient claims it was an accident, it is incumbent upon the hospital or facility where the individual is held (which is typically at least 72 hours) to do an in-depth analysis of whether the person is a danger to themselves or others. While in this scenario it may've been an inadvertent overdose, the empirical evidence suggests it could have been intentional as the practitioner cannot see into the thoughts and motivations behind the patient's actions. Even taking the patient at face-value, addiction to the extent of overdose is also a mental health issue, which may cause a person to be a danger to themselves. From a clinical perspective, it is much more likely than not that one of the two scenarios occurred, versus a truly mistaken overdose. One would need to mistake their actions numerous times in a day to take so much as to overdose.
If you look at it from the inverse perspective, if the facility failed to keep a person who'd just overdosed, or the first responder failed to initiate a hold and the person later died, minimally they would be liable if sued by the family in an action for wrongful death. The unfortunate facts are that if a person was set on committing suicide, it unlikely they would be forthcoming with that fact, for this very reason (the mandatory hold), so a person's word cannot be the determining factor. Even if someone was not intentionally trying to take their life, having taken enough Xanax to cause medical overdose would suggest the potential that even if not suicidal, the individual was at a minimum abusing the medication by taking much more than prescribed (or in a way that is contraindicated - such as with alcohol or other depressants) and potentially suffering from benzodiazepine addiction. Either way, if the hold was not initiated or cut short - and then someone ended up dying from an overdoes - the responsibility and potential liability is the same.
A person who is suicidal can reassess what may be a snap decision, or have a chemical imbalance stabilized, or a severe addiction identified in that amount of time. For the person who ctually takes so much medication as to mistakenly cause overdose, this is certainly inconvenient; however, 72 hours is a short time in the grand scheme of things to potentially save a life. The law will nearly always err on the side of safety and prevention.