Honestly, it happens when I get some weird idea in my head that I can't stop thinking about, and a sort of mania takes over and gives me the energy and drive to work on it for hours on end.
In terms of where to find the time, there are 24 hours in the day, at least 8 for working the 9-5.