Or maybe not. Some species are very resistant to cancer. For example, bats basically never get it, even though they live up to 40 years.
Would they get cancer if they lived for 400 years? Maybe not either. Their immune systems are very good, better than ours.
(We humans don't really want to acknowledge that some other animals may have better immune systems, or any other systems, at their disposal.)
On the other end of the scale, mice die of cancer while not even three years old, because their immune systems are really bad at fighting cancer cells.
Cancer in mammals seems to be a function of failing immune systems rather than raw age in numbers. In some species, including us humans, weakening of the immune system goes hand in hand with aging. But in others it does not.
Peto's paradox - and the existence of whales in particular.
If cancer really is an inevitability, then whales, who have both livespan limits longer than that of humans, and enormous bodies with a staggering amount of living cells, would be full of cancer. They aren't.
Clearly, humans must have better innate cancer suppression than mice, and whales must have better innate cancer suppression than humans.
There are some hints that this may come down to programmed cell death and DNA repair mechanisms (i.e. the p53 pathway) more than the immune system tweaks - with immune response being the "last resort" of cancer suppression. But we also don't know enough about the immune system to be able to examine it the same detail we can examine the DNA repair pathways.
The correct way to phrase this is that humans have a level of cancer that does not greatly impede the fitness of the species in having offspring. We didn't hill climb into other evolutionary protective mechanisms because they either were not discovered or did not convey appropriate fitness benefits.
Our evolutionary biology doesn't "care" if we get cancer. Just that we have healthy children and can rear them for one or two generations. That was a (locally) optimal algorithm.
We have plenty of in-built checks and protections in our molecular biology, and they are sufficient to expand the species.