As an author, I'm generally already thinking about my next book long before I'm even finished with the one I'm currently working on. But that doesn't mean everything I write is bound for eventual publication.
Sometimes, I write to get to know my characters better. (I've written many backstory scenes that will never make it to the finished book.) ... Sometimes, midway through a manuscript, I discover that it's not really the story I want to tell. (Often, I'll come back to those stories months or years later. But not always.) ... And sometimes I write just for fun!