It depends - why would one start writing a piece in the first place?
Some of my music has been inspired by witnessing events, musical or otherwise, some by a musical idea I had, and some, usually the worst, because I had to, like an assessment.
I find it almost impossible to force composition, I'm writing for an assessment at the moment and it's not rewarding at all! but I've recently finished a piano quintet that flowed quite naturally and was a reaction to personal events combined with the hearing of the Schnittke quintet.
Before that I had been doing some experiments with the electronic modulation of sounds and I had a request for an avante-garde song - that one came easily as I already had musical ideas on the go which I could translate into a discrete piece.
Another way entirely, though for me usually less successful is to try and find inspiration in the expression of a form or process, I've recently been dabbling in rhythmic serialism and the formal organisation of spatial elements (not at all cos i went to the stockhausen prom

) which gives the piece on a fundamental level a continuity that you can then build on.