Carcinogen is a catch-all term for substances that lead to increased formation of cancers. There are actually several ways a carcinogenic substance can lead to cancer. One way is by attacking the DNA itself. In most cells there is a very large and delicate balance between many genes, for example, sometimes a cell needs to grow quickly, and one gene promotes this signal. However, sometimes this process must be suppressed, which is a function carried out by two different genes. Sometimes, one, or a combination of genes may be damaged, leading to things like uncontrolled proliferation, movement to areas the cell doesn't usually belong, and lack of self-destruction.
Genetics plays an important process in the part above, as in some familys certain genes will already be mutated in such a way that there is a higher risk for these genes working together to become unbalanced. Conversely, some people may have genes that are particularly protective. Outside of DNA these substances may affect parts of the cell and the processes themselves, for example by mimicking a hormone or protein to promote a signal. Lastly, actual cell damage and death can promote an immune reaction from the host of the cancer. Recent research has shown that in some cases some cancers hijack the immune response to feed and protects themselves, and therefore widespread damage and inflammation may also contribute to cancer formation.