Confounding is the main reason data that was not produced by an experiment gives misleading causal answers.
A confounder sits upstream of both the treatment and the outcome, so it creates a link even when there is no effect.
It can also hide a real effect, or flip its sign, depending on how it acts.
For example, older patients get a new drug less often and also recover less often, so the drug looks better than it is.
The fix is to compare treated and untreated units that share the same value of the confounder.
Stratifying does this directly, by comparing within age groups and then combining the results.
Regression models adjust for confounders by including them as extra columns.
Matching pairs similar treated and untreated units so that the groups are balanced on the confounders.
All these methods adjust only for confounders that were measured.
Unmeasured confounding is a big reason why findings from such data are often overturned by later trials.
Adjusting for the wrong variables can make things worse, especially variables that the treatment itself changes.
For example, adjusting for blood pressure when studying a drug that works by lowering it hides the drug's effect.
Choosing confounders well needs knowledge of the subject, not just correlations in the data.
In practice, analysts list likely confounders before analysing, and report how sensitive the result is to missing ones.
The usual mistake is adding every available column as an adjustment, which can introduce bias rather than remove it.