I am self-taught, and I think the important thing was that I kept learning not because I knew what I wanted to learn, but because I knew what I wanted to build, and then had to learn the steps to get there.
TLDR: Find a problem you want to fix, or people with a problem you'd like to help, and then learn how you can help them, and then learn the tech that needs to be implemented to solve that problem.
I will say, I had some early success, and I think that actually hurt me rather than helped me, as I had this huge ego about the things I was able to do with code. I wish I was more open to learning earlier, but I didn't have the university background of knowing how to learn, and basically escaped high school as soon as I could, so learning didn't become a thing for me until much later in life.
Here's my story...
I was very fortunate to have gotten into programming because a start-up I had worked at as a PM told me the way I wanted to tackle a project was "impossible". We were doing acoustic matching of music, and needed a large library to train on (back in 2005 or 2006).
I indexed MySpace "hidden" urls to get access to the music library and built a pandora type service from that. It didn't work great, but there was a huge music festival coming to town, and so I used the indexing code I had built to was able to build a concert search engine because I had access to the data (https://techcrunch.com/2008/10/27/hearwhere-lets-you-discove...)
From there, I was talking to a friend and his wife about the boring horrible data entry job his wife was doing, and they both worked for the same company. I explained that a computer could do the job better and faster, and they introduced me to the CTO to explain my thoughts. I explained it to him, and he said "I'm not sure how you think this will work, but we'll pay you to make it", so I built an ML system for them, and they went from having (if I remember correctly) 12 data entry people full-time to the job being 2 people about 5 hours a month. The people were much happier not having to do the painstaking job they did before. A few of the other data people got new jobs in the company and were much happier, I hope those that left also found better work.
Then I tried to teach computers how to cook and failed miserably, I worked at a few startups that went no where.
Then I took over an existing "metaverse" project (pre-metaverse - 2015), and made it function better so it could be usable to a wider audience. Ayvri (https://ayvri.com) is loved by the paragliding community, and a few of our API customers, but we're shutting down the consumer facing portion as the cost of operating for consumers is more than we are taking in as we've grown.
We have a few companies vying to taking on the tech.
Now, the team that built Ayvri are working on improving sleep for millions with a headband that monitors sleep state and uses auditory stimulation to improve the neurological function of the brain during sleep. https://soundmind.co - this is the project which I believe has the most impact, and is REALLY fun to work on. Though, I don't work on the tech stack anymore, the engineers I work with were always better than I am.