Not contagious. Cancer is not a contagious condition so cancer will not be passed from mother to baby. However, some cancers can have a genetic pre-disposition so an offspring can inherit certain types of cancer that could occur in adulthood.
Gene predisposition. If the mother had cancer while she was pregnant, the cancer will not spread to the baby and give the it cancer. If the mother's cancer was in part caused by a mutation in a cancer predisposition gene, it is possible she could pass this gene to her baby (50:50 chance). Depending on the gene, the baby could be at increased risk of developing the same or another cancer.