This is actually a great question - take a look at this discussion from 2015.
This isn't my area of expertise, but my understanding is that elephants have many more copies of TP53, a gene that plays a critical role in regulating the cell cycle (and thus uncontrolled growth that may occur in cancer).
One of the linked papers also states that there was no correlation between body size and cancer in their experiments.
https://www.nature.com/news/how-elephants-avoid-cancer-1.185...