As-salam Alaikum waramotullai, wa barakatuh!
Two scenarios apply to the issue of fasting by pregnant woman and nursing mothers.
First, if a nursing mother is not affected by fasting, and fasting is not too difficult for her and the child does not suffer any difficulty getting the breast milk, then she is obliged to fast.
Secondly, if she fears for herself or her child that the fasting may hinder the flow of breast milk which will make the child to suffer, fasting is not recommended for such mothers. She would have to pay back her fast at the most convenient time probably after Ramadan and before the next Ramadan.
Some of the scholars stated that if she fears for her child, it is mandatory for her not to fast and it may not be pleasing to Allah to endanger the innocent child when you have been granted the leeway to abstain from fast. Surely, anything that will endanger the child and the mother is not allowed during fasting. Allah does not intend for us any hardship as a result of fasting.
The same goes for a pregnant woman. It is proven in the hadith of Anas ibn Maalik al-Ka’bi, narrated by Ahmad and the authors of al-Sunan with a saheeh isnaad, that the Prophet (pbuh) granted them a freedom not to fast, and he regarded them as being like travelers. But they have to make up the fasts later, just like travelers. The scholars explained that they are only allowed not to fast if fasting is too difficult for them, as in the case of one who is sick, or if they fear for their children. The two are related because when the pregnant woman gives birth, she becomes impure from nifaas and also breastfeeding. The point being made here is that when there is not difficulty in the condition of either of them, they will have to fast. Note that fidyatu-toham is not recommended for these people because their condition is not permanent.