The tools used to fortify the body against infection are also one of the causes of the most common form of childhood leukaemia, say researchers.
The machinery used to produce millions of antibodies in the immune system can misfire, making cells more likely to become cancerous.
The UK research group hopes to understand why some children do not respond to treatment.
The findings were published in the journal Nature Genetics.
Patients with leukaemia produce abnormal blood cells, and acute lymphoblastic leukaemia is the commonest form of the blood cancer.
The immune system makes millions of different antibodies, but has only a limited amount of DNA containing instructions for their manufacture.
In order to generate the vast variety of antibodies to protect the body, the DNA gets shuffled around and chunks get deleted.
However, scientists at the Sanger Institute in Cambridgeshire and the Institute of Cancer Research in London discovered the same mechanism for shuffling DNA to make antibodies was also altering the risk of cancer.
In 57 children, the researchers compared each child’s DNA in healthy tissues with the DNA in their cancerous white blood cells.
They showed there were two phases of the disease.
Dr Peter Campbell, of the Sanger Institute, told the BBC: “The first change occurs before birth, but children don’t present with leukaemia until between the ages of four and ten. This delay is associated with further genetic changes.
“We found the secondary genetic changes are mostly driven by bits of DNA being deleted from the cells by the same machinery that immune cells use to generate antibodies.”
It advances the fundamental understanding of the disease, but is unlikely to lead to new therapies. Treatment is effective about 85% of the time.
‘Advances our understanding’
However, in some patients cancerous cells do come back.
The researchers believe the rapidly advancing field of genetics will shed light on why this happens.
“One of the interesting thing that will emerge in the next few years is what the secondary changes mean for survival rates. Pieces of the genome continue to get deleted and it’s likely these cause resistance to treatment,” said Dr Campbell.
Dr Matt Kaiser, the head of research at the charity Leukaemia & Lymphoma Research, said: “We are getting better and better at treating the most common form of childhood leukaemia and now nine in 10 patients survive long-term.
“But the current therapy is gruelling, and for some patients the cancer comes back.
“By using cutting-edge genetic technology, this research truly advances our understanding of the actual biology that drives some of these cancers.
“This knowledge will be invaluable in designing better, more precise treatment, as well as in more smartly predicting how an individual patient’s disease will behave and what their likely outcome will be.”