Based on your last description, I suspect you have a faulty ignition switch.

The switch may be intermittently providing some continuity on the "kill" circuit.

This interferes with (or completely eliminates in some cases) ignition system function.

Replacement switches are readily available.....