However, in situations where both mother and baby are in lethal risk, and the baby's life literally cannot be saved (e.g. uterine cancer detected during early pregnancy) the doctor is justified in focusing on the mother's life, since that which is impossible cannot be morally obligatory (saving the baby, in this case).
You still cannot directly and deliberately kill the baby. But if, in the course of the legitimate therapeutic treatment of the mother (e.g. hysterectomy of cancerous uterus) the baby dies as a "double" (not intended) effect, that can be sadly accepted as the unavoidable reality of the situation.
On the other hand, if it was LATE in the pregnancy and both the mother and the baby COULD be saved, that's different: in that case, you are obliged to actively try to save both.
The Catholic Church does NOT teach that the “life of the mother takes precedence,” in part because that is meaningless.
What the Catholic Church teaches is that no innocent person may ever be directly attacked. I.e., it is never permissible to kill an innocent person AS A MEANS of saving another person.
A pregnant woman MAY undergo some life-saving treatment even if the death of her baby is a foreseeable side-effect.