Nature versus nurture in galaxy formation: the effect of environment on star formation with causal machine learning