Strange issue once in a while.

And while you are moving the shifter around, keep the key-switch in the crank position.
But I would clean the battery terminals and the engine ground, just because. And if your battery cable-clamps are the clamp-on repair parts, I would take those apart too and clean the gunk out,just because.