Why are babies rarely born with cancer?
Nature tends to turn against cancer not towards it. Cancer exists when cells begin to multiply with abnormal features, without correction. Cancer is the consequence of many many harmful mutations, which inhibit the correct reading of DNA.

Cancer takes time to develop, not months, but years. Also, babies don't have old tissues, so there haven't been as many divisions, or as many opportunities for mutations, as a 5 yr old or a 10 yr old has gone through.

Although rare, Neuroblastoma is a cancer that babies CAN be born with. Nerve cells develop early, week 5 of fetal development.

Perhaps someone else could talk more about the biological mechanisms which really make cancer more a reality for older organisms, but probablistically, it doesn't make sense that a newborn baby would have cancer. 

I looked up these links, to try and address your question. 

cancer in general
https://www.cancer.gov/about-cancer/understanding/what-is-cancer

why cancer takes time to develop
https://sites.duke.edu/missiontomars/the-mission/cancer/why-do-most-cancers-take-so-long-to-develop/

cancer in babies
https://blog.dana-farber.org/insight/2015/02/can-babies-be-born-with-cancer/