Cells have several mechanisms to repair DNA damage. These include:
Direct repair where the damage is directly reversed. Excision repair where the damaged DNA is removed and replaced. Mismatch repair which corrects errors that escape proofreading during DNA replication.
When these repair mechanisms fail, the accumulated DNA damage can lead to cancer.