Understanding Out-of-distribution: A Perspective of Data Dynamics