The ability make to make a causal inference depends on the conditional independence of the potential outcomes and the treatment, to speak in counterfactual terms (e.g., Rosenbaum & Rubin, 1983). If potential outcomes are independent of treatment after accounting for the relevant covariates, then you can make a causal inference from the treatment to the outcome.
More simply, this is the idea of no unaccounted-for confounders. If all confounders are accounted for either in statistics or design, then there is no plausible alternative explanation for the observed effect than for the treatment to have caused it. So the reason randomization allows for a causal inference is that it, in theory, produces two balance groups that have no pre-existing differences in their background covariates. If there were pre-existing differences in their background covariates, and the outcomes of the two gorups were compared with a simple t-test, a possible alternative explanation is that the difference in the background covariates between the two groups is the true cause of the observed effect.
Using regression can allow for the estimation of a causal effect if after conditioning on the variables on the regression, there is still an effect, and there are no other variables that could plausibly confound the observed relationship conditional on the included covariates.
Other methods like matching attempt to mimic a randomized experiment in the sense that the two groups are balanced on all relevant covariates prior to effect estimation. Groups can be balanced by design (i.e., with randomization or matching), or by statistics (i.e., with regression or structural models).