For example, take a randomized trial, where half of patients are given a drug, and half a placebo. If we define Y to be the outcome of interest, and X to be 0 when the patient received the placebo and 1 when they received the drug, then a positive outcome would be a correlation between X and Y. A person might object that "correlation does not imply causation", however, we know enough about the causal process involved, to infer that if Y and X are correlated, this must be because X caused Y.
There are many other ways that causation can be inferred, such as instrumental variables, regression discontinuity, or panel regressions. However all these methods require making an assumption about the causal process underlying the statistical distribution. Whether these assumptions are correct is often a matter for debate.