They see a medical professional, the professional makes some recommendation, and then the patient accepts or rejects the recommendation. Neither the medical professional nor the patient know the costs the patient will eventually encounter.
The patient only finds out their costs some months later when they receive one or more bills negotiated between administrative groups and their health insurance provider. Any goods and services have already been rendered, and the patient is now on the hook for whatever the bills happen to see.
Maybe the more "fair" answer is to make medical costs transparent instead of treating medical debt different than other kinds, but the system is broken and needs critical attention either way. This is essentially a path of least resistence.