To be honest I have struggled with this concept when I first encountered it in Range: Why Generalists Triumph in a Specialized World by David Epstein but I remembered that the only reason I started software development is because I really liked math and searching scholarly books and texts, In this book it is shown through evidence and various case studies from athletes to musicians, artists and even scientists that a person with varied interests and pursuits has a better chance of excelling in a certain field because of those varied interests. and I think these same parallels can be found in the software engineering realm, given that the de facto career advice for starting developers is to focus on one technology or field and work on it deeply with companies stressing the need for a an X number of years as a proof of competence, of course, If it’s not broken don’t fix it, people still make great software (arguably) and the whole global economy depends on modern technology made usable by software made by engineers that are specialist, but that doesn’t mean that generalists aren’t as able to solve the same problems and in even come up with better solutions.
So long story short, in your first years as a developer sample as many fields within software development it is proven that it helps in the long term.