Yes sometimes babies in the womb can become infected through the mother in the womb.
So if you get a cold or flu virus while pregnant the virus can sometimes be transmitted to the baby in the womb through the placenta which can then lead to health issues with the unborn and developing baby.
But the baby should not get infected from anything else outside the womb unless the mother gets infected with the sickness.
So you should do your best to avoid getting sick and take medications to prevent the flu and cold virus before you actually do get the cold or flu.
If you do get sick you might want to see a doctor to make sure the baby is still healthy and doing okay in the womb.
If you have a fever of 100 F or more and cannot get the fever down on your own you should go to urgent care or emergency room just to be safe.
Because the fever can cause complications to the unborn baby in the womb.