In my car's case, the same symptoms were caused by a faulty ignition switch, the electric rotational switch that plugs onto the back of the ignition lock. It was a bear to install as half the dash needs to come apart, but now the car starts properly, every time. In my case, the problem slowly got worse and worse over the years, until the switch stopped working altogether. I installed a separate start switch, which worked fine, but it always bothered me until I finally took the bull by the horns this summer.
I paid something like €70 from I think an Ebay vendor in Germany.