You're just asking how do we control for confounding factors in epidemiologic research. There are many ways, included adjusted logistic regression modeling, propensity scores, randomized clinical trials, cohort studies, on and on. I know it may seem like there's too many studies, but you shouldn't worry that there aren't extremely intelligent statisticians and epidemiologists working on these very issues - I collaborate with them daily :)