There are all kinds of opinions to this topic: From “Be a meaningful specific, not a wandering generality.” and “Find your niche!” to “Specialization is for insects.”
A great example for me is Frank Brangwyn who was an artist (specialization) and uses his skill and knowledge to expand in a broad range of artistic media (generalization). He was called a “Jack of all trades”, someone who is good at all, but not really a master of one.
Brangwyn did paintings, drawings, woodworks, illustrations for books and designs for furniture, ceramics, buildings, …. It is estimated that he has produced 12000 works in 89 years of living. That are 135 works a year, starting at 0 years old. Pretty solid. And the bigger chunk of his work is masterful.
The general questions behind this is how to spend the time we have and do we have individual potential that is worth using and developing. There is no right or wrong, just balance.