You get ideas from daydreaming. You get ideas from being bored. You get ideas all the time. The only difference between writers and other people is we notice when we're doing it.
The more books we read, the clearer it becomes that the true function of a writer is to produce a masterpiece and that no other task is of any consequence.