Cancer, as the second leading cause of death worldwide, poses significant challenges to human health and socio-economic development. In recent years, the incidence of cancer has shown a trend toward younger populations, drawing attention to cancer prevention education among college students. However, research on the specific impact of cancer prevention education on the mental health of college students is limited. This study aims to explore the impact of cancer prevention education on the mental health of college students, revealing the mediating role of disease awareness and the moderating roles of psychological resilience and cultural differences. A difference-in-differences (DID) approach was used, involving 1,670 freshmen from a Chinese university, divided into an experimental group (n = 835) and a control group (n = 835). The experimental group received a semester-long cancer prevention education program. Data were collected monthly from November 2022 to June 2023 using the Depression Anxiety Stress Scales (DASS-21) and a custom Disease Awareness Scale. The study found a significant improvement in mental health scores among the experimental group, with an average increase of 14.738 points on the DASS-21 scale (p < 0.001), representing a 23% reduction in stress, anxiety, and depression levels compared to the control group. Disease awareness in the experimental group improved by 17%, as measured by the Disease Awareness Scale, with a mediation effect of 3.563 points (p < 0.001). Furthermore, psychological resilience and cultural differences moderated the impact of the education program, with those scoring higher in resilience showing an additional 8% improvement in mental health scores (moderation effect = 0.892, p < 0.001), and cultural differences accounting for a 5% variance (moderation effect = 0.756, p < 0.001) in the outcomes. This study demonstrates that systematic and scientific cancer prevention education has a significant positive impact on the mental health of college students. Universities should promote comprehensive and personalized health education strategies to improve disease awareness, foster psychological resilience, and emphasize cultural differences, thereby enhancing the overall physical and mental health of college students and promoting their holistic development. This finding provides important empirical support and theoretical basis for the design and implementation of health education in universities.