Could be lots of things, including the ignition switch. They can play up in funny ways, intermittently, but so can lots of other things. You need to work your way through things, eliminating them from the equation. As others have said, next time it happens use a spare plug to check for spark on all 4, if it is the spark your losing say, then it can be dizzy/cap/leads/coil, or possibly ign switch cutting the coil feed. Sometimes they can turn over + over + over, then fire when you let off the key. That is one of a few possible symptoms of a faulty switch. However it may not be a spark or associated parts problem, so you really need to do some inspection, testing and fault finding and get to know your car + components health In general