The simple answer is I have no idea. The complicated answer is I get ideas from real life. My wife knows that if I say something funny, I immediately pull out my phone to write a note, so it can go into a book.
When developing plots, many times I will put the Merry Band of Pirates into an impossible situation and then ask myself ‘how the F*&# can they get out of this mess?’ When I get stuck for an idea, instead of staring at the keyboard, I take the dogs out for a walk, vacuum the house, ride a bike, etc. That always gets the creative part of my brain working.