The Implicit Bias of Heterogeneity towards Invariance and Causality