My experience is that the self-publishing business is a _business_ that generates money from publishing and marketing books. If you decide to self-publish and self-market, all you are doing is skipping the publishing step of recruiting an author, and substituting the step of writing one or more books yourself. The key insight here is that it is a business, and the actual writing of the book is incidental to the succe…
It could also be that you write off the cost of the book-writing as an expense in an experience-establishment communications effort. Like building up your professional resume. In effect you are giving time and maybe a little money to be able to say "I'm an author who has published N books on this subject." That's part of the equation, if not the whole equation, for many people.
My feeling is that this is a holdover from a time when there was a substantial barrier-to-entry for authorship. Back when publishers were the gatekeepers, anybody could write a book, but relatively few were published.
People could vanity-press anything, but nobody would hear about them, because just as publishing was concentrated, so was marketing.
---
But today, anybody can publish a book, and likewise anybody can market a book, super-cheaply. "I wrote X" is worth geometrically less today than it was a decade ago.
If you write a book for other reasons, by all means bask in the reputation. But I find it extremely unlikely that if you are doing it strictly for economic reasons, that writing a book and then marketing it is going to be superior to the many other ways you might have of building your professional resume.
Maybe you should answer a lot of questions on Stack Overflow. Or--like me--become a blowhard on Hacker News.