How can medications affect a fetus?

Depends. Every medication is different....Some are safe with no harmful effects, while others can be extremely harmful to a fetus. Contact your provider to make sure you are on appropriate meds. Don't stop anything you routinely take for medical conditions without first discussing with your provider. Doing so can sometimes cause dangerous situations for you or your baby.
See below. Medications can cross the placenta. This means that medications, drugs and alcohol that the mother is exposed to can also affect the growing baby. In the extreme this can be seen in babies who are born addicted to narcotics, or those who are affected by the other's ingestion of alcohol during pregnancy.