What do you think is more valuable, being an expert for specific topics/stuff as security/database systems/performance engineers or maybe who have expert knowledge in one or two programming languages and perhaps a lot of frameworks and things like that or engineers who know a lot of languages a little bit, to maybe chose the right language for the right "smaller" project?
It certainly all depends if you do consulting/customer projects or have projects of your own with consulting on top, for instance. However, after ten years working extensively with Java and lately some Kotlin in the backend, I would like to know if I should have a much broader knowledge or the desire to learn everything (yeah, well, we all know a couple of languages a little bit). I'm currently learning TypeScript, and most languages, if they are not purely functional, are relatively easy to learn with some experience. But I'll sure lack some depth and to learn the major frontend concepts for instance underlying the frameworks, build tools, you name it will certainly need much more time than 2 or 3 months.
I think the most interesting from my perspective, however, is a much deeper knowledge of specific topics (for instance, lately, I'm all about reading latency/throughput-related stuff, as I'm extensively profiling my OSS database project and I'm reading books from experts as Brendan Gregg...).
What's your opinion on the topic? For example, be an expert in something or be able to use the right tool for the right project at hand, but maybe not be able to use it in the best idiomatic way or not know all the pitfalls and stuff you'd probably know if you're more specialized?
If you want to make the most money possible, and are OK with a much higher risk of being unemployable at some point, become a specialist. The field is a lot narrower for specialists and it can quickly become full, leaving you without work. As time progresses, it's likely need for your area of expertise will dissolve unless you are an expert in something abstract (e.g. one day no one will care much about deep knowledge of the Java language specifically, but knowledge of how a bytecode VM, JIT capable OOP language works in general will be valuable for a long time).
If you are OK with taking some "losses" in terms of how much money you'll eventually make, and prefer less risk of unemployment become a generalist. You won't be paid as much because you do not hold a scarce knowledge commodity, but you'll have a much wider field of opportunity to find jobs that want to leverage some of the knowledge you do posses.
Finally, this is all assuming you want to stay in a focused technical role your whole life. If your goal is to eventually do something else like run your own company, start becoming a generalist immediately.