The transmission position sensor tells the PCM computer what you want to do with the transmission. The PCM computer then talks to the ECM computer and the ECM tells the PCM what solenoids to activate depending on rpm, throttle position, etc. I can't guarantee that is the issue but nothing you've said would indicate otherwise and it sure seems to me to fit the symptoms. A failing switch is telling the computers that you are moving the shift lever to these positions even though you aren't.
"It is useless to do with more what can be done with less." William of Occam