Environment-Aware Dynamic Graph Learning for Out-of-Distribution Generalization