First off, as others have advised:
- Start writing.
- Write well.
- Hone your craft.
Decide what kind of a writer you are and what style(s) you want to develop.
Writing is a discipline - some use it as therapy, others for personal reasons. Writing is not publishing. One leads to the other.
Publishing depends on writing, but it is a business - it could take the form of an entertainment business, an informational business, an educational business.
And if you are getting into publishing, you need to hone your business sense as well as your craft. It takes time to build a fan base and find your market. Short-termism doesn't work well long term.
If you write 20 drafts, discard them because you feel they're not good enough, pitch a load of proposals to publishers and agents and get rejected, self-publish a couple of titles and get a few dozen sales and are still keen to keep going, to get better, to keep building, then the real work starts.
You may be lucky and get a break - most don't. Those that do often walk the talk - they use on-line resources, they enter competitions, win prizes, attend conferences, get seen ... their writing has to be good enough for people to want to read it, or the information they are sharing be interesting enough for people to want to invest in it. Ideally both.
As for which book publishing avenue to go down, much depends these days on the book. If it's niche, and designed as a loss leader, then self-publish. If it's mainstream, you could do both options. If it's literary, and you want the kudos of mainstream publishing (which is still there, but things are changing with sales of self-published books outstripping traditionally published ones). Quite a few writers and publishers are doing well with places like KickStarter or Patreon.
One thing that hasn't been mentioned so far on here is the topic of awards - self-published authors are often at a disadvantage here, and established publishers typically have a well-oiled machine designed to feed books into prize selection committees with the hope of boosting sales.
There's a good article on the pros and cons with a quiz you can take on Reedsy here.
The other question you have to ask yourself is whether you're a one-book author (nothing wrong with that - just be clear on that), whether you want to write about a main interest to provide an additional outlet to get your message out there, or whether you want to take up writing as a career. Either way, book sales will be important - and in the latter case, will be useful in helping you decide which route to go.