Alleviating Confounding Effects with Contrastive Learning in Recommendation