As a (former) automotive software engineer, I've spent some time working on car engine controllers.
As @Snow says, the gear lever on an automatic selects whether you're in Park, Reverse, Neutral, Drive or Low gear. The gear selection is arranged in that order, so in the industry you will frequently find this called the PRNDL, to specifically identify the lever (or the sensors monitoring the lever's position) and not any sensor within the transmission itself.
Older cars used a separate switch within the PRNDL or transmission to control the reversing lamp(s). These days, most things are under software control, and there is an increasing drive to reduce sensors for reasons of reliability and cost-saving. On a modern car therefore you will find the reversing lamp driven by software control. The PRNDL position is measured over its travel (usually using a potentiometer, but sometimes a rotary encoder), and using this measurement the reversing lamp is turned on when the PRNDL is in the reverse-gear position. This is just one part of the software finding what gear the car is in, of course, which is used for pedal demand maps and various other settings.
Of course with the PRNDL gear layout, you have to go through Reverse to get to Park. The software therefore uses a timeout mechanism to decide whether to light the reversing lamp, to reduce the effect you describe. The driver needs to have been in Reverse for a short time (maybe half a second, perhaps longer) before the reversing lamp is lit. If the vehicle calibrators have not been conservative with this timeout, it's quite possible that the reversing lamp can flash inadvertently. There can also be a problem with old/worn/sticking gear levers where the user cannot move it through gear positions so easily, meaning that it spends longer than usual in the Reverse position.