Mercedes Repair Questions? Ask a Mechanic for Answers ASAP
I'd 1st investigate the connections to the brake pedal switch and the wiring to it for any crimp damage or fraying. Ideally use a multimeter to check that the switch is working OK. This is because the gearbox controller won't allow the lever to shift from park until it sees that your foot is on the brakes
There should be 2 switches one for the brake lights and the other for the gearbox and both are located at the top of the brake pedal in the drivers footwell.
If this is OK then check the selector lever linkage for any broken parts and or missing bolts or if a bolt is partially out and is jamming things up