How Syntax Specialization Emerges in Language Models