Specialists trade-off resilience for compounding gains of expertise in their field of interest. The compounding gains arise from building on past knowledge, creating a wider competitive moat in your field of expertise.

Generalists trade-off compounding gains of expertise for resilience to change in their fields of interest. The resilience comes from diversification of your capabilities useful in the field.

Which trade off you take depends on the rate of change in the area under consideration and your ability to stay the path.

Generalise if the field under consideration is in flux. The compounding, stable gains of specialization may not have enough time to payoff. The field would have moved on from the topic of specialization.

Specialise if the field under consideration is stable. In such an environment, a generalists' low depth would be an easy moat for others to climb and overcome the competitive advantage of generalization.

Once the ability to synthesize across multiple different areas due to generalization is gained it becomes a specialization. Assume in the generalist phase, an understanding of A and B was gained. Once this understanding of A and B can be synthesized to gain a concrete, competitive advantage, you've become a specialist in A&B. This provides a path to specialization for generalists as their field of interest stabilizes and the rate of change slows down.