Actually the key is to be expert in one and be agile enough to learn the others fairly quick and in a shallow way if the hours demands it.
Both ways are fine, some people like to specialise and others like to be generalists. But ultimately T-shaped skillsets are the most common in reality - most people know a little about a lot, but have an area where they are most effective (and enjoy working the most). Plus no matter what you should have some level of understanding about what everyone around you is doing.
Remember there's a big difference between knowing something well enough to do it; and knowing it well enough to work well with people who do it.
Imho, it is important to not only focus on one thing. A jack of all trades often has an easier time approaching a problem and working together with others, because they know so many things. However, when it comes to the implementation, an expert of that one thing will always be better.
That's why I try to do many different things (not only in my professional life), and master a few which are important to me. When it comes to programming, I try to master JS and Rust, but I can also use stuff like PowerShell and Bash a bit, so that I can automate stuff if I have to.
It's better to be a T shaped developer.

This helps you become a better team player too. If you have a good understanding of the process involved in front-end, back-end, product, design etc, you can practice empathy better when working with other people.
You get to learn a lot from different languages, frameworks, philosophies etc that you can use in your work.
If you wanna start something on your own at one point of your life, you can do it by yourself
I would like to think of it this way. Most full time jobs require us to use one specific language like Java or JavaScript or Python and what not. But there comes a point in every developer's life when they need to build custom tools to assist with their development, this is when there's a need for what I call utility languages, I use Python and Go for all my utility scripts.
It's more of a sliding scale with the independent variable being how old you are, and how long you've been developing. When you're younger or just getting started in development, you should definitely cast a wide net. As you get older, and depending also on whether you develop as a hobby or professionally, you might want to narrow your focus, shifting your gaze every now and then just to avoid tunnel vision.
The end game of this whole process is essentially to get develop a final product or solve a problem, so the scope of the product or problem is also a factor. Can you ramp up in languages / frameworks fast enough to solve a bunch of separate problems for a disparate variety of customers? Then perhaps being a polyglot and freelancer is for you. Are you trying to solve a single large problem or build a large product? Then maybe focus on just a handful of cohesive technologies.
The benefit of the latter approach is that if you can master a single technology well enough, then you could potentially gain one of those "passive income streams" I often hear people talk about, where you've built a thing and the thing can continue to pay off long after you've built it simply by bringing in / bringing back customers over time, and all you need to do afterwards is maintenance and minor updates while focusing on other projects.
Sai Kishore Komanduri
Engineering an eGovernance Product | Hashnode Alumnus | I love pixel art
J03
Just another bit in the byte
Tommy Hodgins
CSS & Element Queries
I think too much dedication to one language, over learning programming is a bit of a waste. Languages are just commonly agreed upon abstractions - it's entirely possible you might find yourself needing to solve a problem where the simplest way to solve it is by using, or even inventing a different language than what you do normally. That's totally fine :D Programming languages are kind of like clothes, you can change them as the activities you're doing are different!