Vaccines, such as the HPV vaccine and the Hepatitis B vaccine, play a crucial role in preventing cancers caused by infections. The HPV vaccine can significantly reduce the risk of cervical cancer, while the Hepatitis B vaccine helps prevent liver cancer by protecting against Hepatitis B virus infection.