Cancer happens when people inherit gene changes or develop gene damage due to exposure to external factors over time (smoking, sun exposure, etc). When cells are damaged beyond repair they can divide uncontrollably causing tumors.
For normal cells to become cancerous is a multi-step process that typically takes several years. The time required for cancer to develop also provides us with the opportunity to intervene and stop or reverse cellular damage.
We cannot (yet) change our genes but we can change our exposure to factors that can cause DNA damage and lead to cancer. Although we know many of these factors that increase the risk for cancer, we cannot precisely measure how much each factor influences risk.