How? This is what I never understood. Every domain expert I’ve ever knowing is because they’ve already I can spend all the time I have reading and toying around in a subject, but until I have real concrete experience to guide me, it’s usually pretty difficult to become an “expert” in anything. I know how to become an advanced hobbyist, but thats never in my life translated to someone being willing to pay me over say, and already established expert
I've drifted across projects in different industries (FMCG, investment funds, ad agencies, startups of various sorts) and like I said I had a long project (over two years) for an executive search firm and got to see the ins and outs of how everything works from strategy to technology. I could be drifting to find clients in yet another vertical but I've decided to stay put for at least a few years. So to answer your question, in my particular case: I drifted, stumbled upon something by chance, and then took a conscious decision to stay.
how?
From GP comment: “either start an open source project, or become the main collaborator in one.”
If you're a dev, one approach to specialization is to align with the tooling associated with common "profit center" processes. Become a Salesforce/Hubspot/Odoo/Shopify developer. If you're not interested in developing, you can specialize in learning one specific ecosystem really well and then teach companies -- typically SMBs -- how to set themselves up and organize their operations around it.