Cancer vaccines work by introducing antigens associated with cancer cells into the body. These antigens train the immune system to recognize and attack cancer cells. When the immune system encounters these antigens again, it can mount a targeted response to eliminate the cancer cells, thereby slowing down or stopping the progression of the disease.