Vaccines could theoretically be used to train the immune system to essentially attack cancer cells in much the same way we already use immunotherapy. Though as far as I understand it, we have yet to fully develope one.
I'm a bit concerned about that TBH. I'm not a doctor or medical researcher though so if they make one I'll probably be an early adopter anyway. But since cancer cells are body cells with a problem, it feels like a screw up on a cancer vaccine would just lead to some exciting new autoimmune disease.
Vaccines at a simple level just train your immune system to attack certain proteins. If you could identify a protein that differentiates cancer cells from healthy cells then you could make a vaccine for cancer.
I do not have a degree in biology, take this info with a grain of salt. If a credentialed individual has better info, please speak up.