In one case you're talking about a doctor who was frankly the wrong doctor for this person, although I'm not entirely happy about the marketplace argument in medical matters. The bakery analogy doesn't hold water when comparing to a time sensitive emergency, which to me is more an issue of the general problems in the U.S. medical system. In principle a doctor acting on his conscience is not the same at all as the state banning something.
Except it wasn't only one doctor.
Her ophthalmologist suspected a stroke in her optic nerve and told her the condition can be caused by pregnancy, but Houshmand was stuck in a Catch-22: The pregnancy was now also preventing treatment. Doctors told her that she needed steroids and blood thinners and a specific type of MRI that could make sure there wasn’t something even more serious happening. But she couldn’t get any of those things because they could endanger her fetus.
Houshmand decided she wanted an abortion. She wasn’t willing to risk losing eyesight and continuing to be in pain, vomiting over and over, with no solution … not for an eight-week pregnancy. But her doctors couldn’t help her — abortion wasn’t even an option they brought up. Houshmand had to find a private clinic that could treat her on her own. After the abortion she found out the truth: She had a life-threatening infection in her optic nerve.
As long as she was pregnant, none of the doctors Houshmand encountered would do the things that needed to happen to diagnose her — or treat her.
She saw multiple doctors, not just one who had a problem with her pregnancy. And it was because the procedures to diagnose and treat her could endanger the fetus.
Which is the Catch-22: you can't know if the illness is serious enough to kill the fetus until it is diagnosed, but you can't diagnose the illness without killing the fetus. You either have to risk killing the fetus or wait until the illness is so serious that it is obvious the mother will die--at which point it may be too late to save the mother (and often the fetus).

So the only way to know if the illness is serious enough to kill the fetus is to kill the fetus. But it isn't medically necessary at that point, because no one knows if it is that serious. So it is an illegal abortion, and the doctor should go to jail.
So the doctor has a choice of killing the fetus but saving the mother--and possibly going to jail (in some cases possibly for life)--or risk the life of both by holding off as long as he can--and possibly getting a malpractice suit (with a good chance of beating it).
Which do you think most doctors will do most of the time?

Of course, the mother could choose to terminate the pregnancy herself.
Except that now she can't in many states because there is no exception for "mother believes it is medically necessary."The mother doesn't get to make her own medical decisions. Only the doctors can do that. And the doctors are incentivized not to make the decision that might cost the fetus' life, because the penalties for making the wrong decision are much worse in that case, even though it will cost of life of the mother and sometimes the fetus in a number of such cases.
And it is pretty common for sick pregnant people to end up squeezed in that vise, said Dr. Lisa Harris, a professor of obstetrics and gynecology at the University of Michigan who specializes in treating pregnant patients with complex medical problems. While she can remember cases where death was certain if an abortion couldn’t be performed — a patient with heart and lung failure, for example — they only come up maybe once a year in her work. But patients like Houshmand happen all the time, she said. “Maybe it’s a 30 or 50 percent chance that someone might die. And they might not die immediately. Maybe it would be in the next week or month, or even year or beyond.”