Updated May 11, 2018
Basically, it tends to be a buildup of many genetic mutations, over time.
For example, you could be exposed to industrial chemicals, cigarettes, or even substances from normal cooked hamburgers, which cause mistakes when your cells divide, and are making a new copy of your DNA.
Also, you could be exposed to too much UV light (e.g. from too much time outdoors in the sun), and that can damage your DNA, causing problems with making the new copies.
Eventually, enough mutations can happen that, a cell gets out of control.
That cell can start replicating very rapidly, making more copies, with even more mistakes, because its control mechanisms are broken.
The chromosomes (with your DNA) gradually get more disorganised, due to the copying dysfunctions. A cell could end up with many more chromosomes than the usual 46, and can mix up the pieces that belong on different chromosomes. You can end up with super-large chromosomes, and even circular chromosomes.
It is kind of like taking an encyclopedia with 46 books, and then randomly changing some words, and swapping chapters and pages.
Some situations like this would just cause the cell to die, and that is the end of the matter.
With cancer, the cells have mutations that make them more efficient, in terms of growing fast. This also makes them hungry, and they can send signals to surrounding tissue to grow more blood vessels to feed to tumour. This way, a tumour can pull a lot of glucose and other nutrients towards itself, at the expense of the rest of your body, out-competing your healthy cells. This is part of how cancer can be fatal to the person. In the past, I have cared for a couple of terminal cancer patients, and it is painful for all involved (but much more painful for the dying person).
Healthy cells are “differentiated” (programmed to be a certain type), which is why some are liver cells, or skin cells, or muscle cells, or nerve cells. However cancer cells become less specific, in their genetic expression, their structure, and the substances they produce.
All of your healthy cells (except red blood cells) have a full copy of your DNA genome, but only some genes are permanently turned either on or off, depending on the type of tissue. This set of on/off switches (technical terms: C-methylation and histone-acetylation) is why your tissues and organs are different to each other. In cancer cells, the on/off mechanisms are broken.
Healthy cells tend to have a certain useful life, before they die (and are recycled by the body). Also, there is a process called “apoptosis”, which is programmed cell death, and can happen when a cell is damaged, and can stop the mutation problem right there. However, cancer cells also have this mechanism broken, and so they just keep living and replicating. As long as they have food, the right temperature, pH, etc, they are “immortal”.
Cancer cell lines used in scientific research (such as HeLa) have apparently changed significantly over time, and different variations exist. But they are still undifferentiated and immortal.