Implicit Gradient Alignment in Distributed and Federated Learning