The women in the WHI [Women’s Health Initiative] study had filled in questionnaires regarding their lifestyle and other characteristics of their lives including coffee drinking habits and whether they had ever had skin cancer. Researchers found that about eight in every 100 women reported having had non-melanoma skin cancer.

“Daily consumption of caffeinated coffee with was associated with a dose-related decreased prevalence of NMSC (non-melanoma skin cancer) of nearly 5 percent for each cup.” Thus the calculation of 6 cups associated with a 30 percent reduction.

In looking at the results of a study like this it is important to note that it was a cross-sectional study. This means that it only looks at data collected during one point in time so it is not able to establish what events may cause a result or track trends in the women’s behavior.

https://www.empowher.com/melanoma/content/can-drinking-coffee-help-prevent-skin-cancer