Because the child was being nourished by the mother's blood supply while being filtered through the placenta. Since this type of cancer is not spread through blood, it would not have affected the baby.
This is a good example to show people that an unborn child is not just a growth in a woman, but a completely seperate person developing inside of a woman.