Cancer vaccines work by exposing the immune system to antigens specific to cancer cells. These antigens can be proteins or other molecules that are often found on the surface of cancer cells but not on normal cells. The immune system is then activated to recognize and destroy cells expressing these antigens, thereby targeting the cancer.