Revisiting Theory of Contrastive Learning for Domain Generalization