I don't think anyone really knows how a story takes shape. When it's done you try to explain how it happened, but every effort, at least in my case, is insufficient. There is a before, made up of fragments of memory, and an after, when the story begins.
The Paris Review, Issue 212, Spring 2015, Art of Fiction No. 228