I didn't see the show so I don't know what types of scenarios babies would be left with their mothers. Ultimately the person who matters most is the baby and what is best for them long term.
I can imagine scenarios where in a safe controlled environment keeping mother and baby together could be beneficial, specifically for short sentences - so it's not like you have a crawling/toddling baby in a prison environment? Or I'd imagine removing an older baby or toddler from their mother would be more traumatic for the baby than a newborn going into the care of someone who will bond and love them.
Though it's a truly crap situation where there's probably no-win really.
I also believe Not all women are going to be good mothers, that love does not conquer all, that a maternal bond is Not automatic and binding or that the best place for a baby is always with their mother. I would hazard a guess and say in most scenarios where a woman has committed a serious enough crime to be jailed that a baby would be better off with someone else. I dont know anyone in jail but i do know people who havent gone to jail ; in the context of if that If they are walking around free to reOffend then what Does someone need to do to go to jail.