What Do Learning Dynamics Reveal About Generalization in LLM Reasoning?