If you want to make money writing books, then you need to make sure that your book sales go on for years.
The question though, is how do you do that? How do you make sure that you can keep on selling copies of your books for years to come?
The answer is simple.
You need to write more books that your readers want to read.
And it does not matter if you're writing fiction or non-fiction. The advice I'm going to give you works for both.
What you need to do is not just write a book, but write a series of books. That way, once someone has read your book, they can come back for more.
The first thing you need to do is plot out your series. Then each book you write has to be a complete book in itself (needs a satisfactory ending or conclusion) plus it needs to keep your readers hungry for more.
If you write fiction, then it's easy to write an ongoing saga split into a series of books, just like the Harry Potter novels did. Each one was a book on its own, but at the same time, the story of the three main characters, just kept going and going as different problems arose for them in each consecutive book.
If you write non-fiction, then you need to write a series of books all based on the same topic. For instance, if you want to write about dogs, you could write one big generic book, or you could split it down into more detailed books about dog health, dog training, breeding, looking after a puppy, grooming, showing and so forth.
That way, as your reader's dog grows from puppy to adult, they can keep buying books about how to look after it. And if it's one of your books that they started with, and you've advertised your other books in the back of each one, then chances are good that they'll stick with the same author.
And it's the same with fiction. Once your readers get to know and like your main characters, they'll want to read more about them. Or you could write about different characters but in the same place, like a haunted house that tries to kill people who stay there, or a series of horror books about zombies, or a series of Western novels or romance books.
Once you start thinking about it and researching for ideas, you'll be amazed at what you can come up with.
But the important thing is to keep writing, publishing and marketing every book you write.