When we first see Dr. M’Benga (chronologically), he is the Enterprise’s chief medical officer. When we see him again, he is still on the Enterprise, but working under Dr. McCoy’s command and, if he was on the ship at the time, under Dr. Piper’s command as well (Dr. Piper was CMO in Where No Man Has Gone Before).
So why do you think he was demoted to a secondary position? Was it something to do with his actions as the Butcher of J’Gal or his killing of Ruh? You would think he wouldn’t be on the Enterprise at all if so. Did Pike demote him? Did Kirk demote him? Was it on orders from Starfleet Command?
What do you think was the reason why McCoy became his superior officer?
This seems likely given that in the timeline where Pike was still in command in 2266 having avoided good accident M’Benga was still CMO. I would imagine that having give through all that shit he wanted to step back a bit and let someone else run the department.