The gear selector in my Prius developed the same symptoms of flipping into the wrong gear. It is a plastic part that warps in the heat and then the sensors do not work as intended. I was able to buy a used replacement for $70, and the installation was easy once I figured out how to remove some trim.
I'm not really suggesting that a 2019 LEAF has exactly the same cause, but the malfunction does sound consistent with a faulty gear selector mechanism.
2013 LEAF 'S' Model with QC & rear-view camera
Bought Jan 2017 from N. California
Two years in Colorado, now in NM
03/18: 58 Ahr, 28k miles
11/18: 56.16 Ahr, 30k miles
09/20: 54.3 Ahr; 38k miles
2018 Tesla Model 3 LR, Delivered 6/2018