I have an odd habit of getting ideas for stories in college. It's not just with the people around me. Most of the time its actually what we're studying that triggers of the gears in my head off. I'm like a factory... only the physical products don't often get shipped off.
Lets take a few recent examples of this; I've mentioned my sin story. This came about during a lecture on Dr Faustus. The slight mention of the seven deadly sins kind of sorted that one out. (note to self: write more of that book!) Another idea came about during a cross-over between two lectures; there was a discussion about the plague to contextualise another of the tragedies we were studying, and then we had a lecture in Philosophy about a particular political philosophy. The mash-up of two lectures made a book. Today, I had the wonderful idea of a comedy story come into my head... We were looking at New Comedy in Rome (to show what Shakespeare did differently), and a single line in the PowerPoint got a fat man dance-walking into a town. Yeah, a fat guy. Deal with it.
This isn't the only stuff that happens. I had a recurring series of ideas all about a world built on Morals. That description does the idea no justice, but I don't want to give it all away. Other times, it's just something in someone's life that triggers an idea. Those ones are the risky ones to write; they get very personal. First drafts of them, even if I like how they turned out, have to be combed to remove references to real life. Usually there are a lot of references to real life.
Situations are strange for ideas. I have a strange memory-recall thing... if I go somewhere I've been before, I get sort of flashbacks of something that happened there (in my life, obviously...). All the significant people of the situation haunt the place in a very polite manner, some more than others, depending on how much I'm thinking about them. These flashbacks lead to stories coming into my head. I cannot help my memory-recall doing this. It's just less useful in exams when I can't remember the details that aren't already jotted down!
I don't quite know why I get ideas so easily in certain circumstances. It's not something I think could be taught to people. The best advice I can give is to just open yourself up to the world, let fiction and life cross over a subtle line that lets one work off the other. Reflecting on experiences that stick out also help, so keep a journal. I did find that one series of events that have inspired a story (that I haven't yet written) were fresh on my memory because I'd been looking over relevant journal entries about them before revisiting the places in which the events took place. This doesn't work for fiction that takes place in entirely fictional worlds, or in places we've never visited before, but it works wonders if you're setting a story somewhere that just looks or feels like the location of your memories.
And for crying out loud, don't be afraid to use your memories. As John Green puts it, "For me at least, fiction is the only way I can twist my lying memories into something true."