My path involved working at a series of tiny startups through the first 15 years of my career - the 1990s and early 2000s. At the smallest, I was the only engineer. At the largest, there were 8. At that scale, you learn to do everything (seriously: front end, back end, databases, assembling servers, networking the office, setting literal rat traps, cleaning the cat litter after "upgrading" the rat traps, ...). You also get an opportunity to get to know people very well and build a lot of mutual trust with some of them.
In 2005, the head of engineering from the "big" startup was helping to start a new subsidiary of an established tech company and needed someone to develop indexing and search for the device mentioned above. He asked me to join.
In 2010, the head of marketing at one of those startups was now an executive at a soon-to-IPO company who needed to scale their ad delivery system. She asked me to join.
Both of those relationships had turned into friendships long before they asked me to join their newer endeavors. They knew what I was good at and what motivated me. That resulting in me being deeply trusted the day I joined and being given a lot of freedom to create solutions. So, I guess one way to get this kind of work is experience, relationship building, and some luck.
I would love to have a career working on problems like this but can't imagine how I'd get a job doing anything but commonplace back-end work.