The opposite was also discovered (dairy increases cancer risk):
https://pubmed.ncbi.nlm.nih.gov/34788365/
It could well be that it is not diary or meat but the amount of glucose/fructose one eats which really affects this. We must go back to molecular level proofs rather than these kind of statistical studies where you cannot control everything (apart from mouse models which most people reject for being a mouse model)
“There are many studies trying to decipher the link between diet and human health, and it’s very difficult to understand the underlying mechanisms because of the wide variety of foods people eat. But if we focus on just the nutrients and metabolites derived from food, we begin to see how they influence physiology and pathology,” said Jing Chen, PhD, the Janet Davison Rowley Distinguished Service Professor of Medicine at UChicago and one of the senior authors of the new study.Your missing puzzle piece is the fact that we do multivariate adjustment models to adjust for cofounders.
You might as well ask "How do we know whether it's the cigarettes or the fact that people who don't smoke also tend to exercise and eat vegetables? I guess we can never know!"