It should be mentioned that Spock was "

happiest

" serving under Kirk and preferred to do so. Vulcan's have a long life and he was in no hurry. He was just still a captain from when he was the in charge of the Enterprise pre-twok when Kirk had once again accepted promotion; while Scotty was a Captain by rank only and never had any desire to command his own ship. He just wanted to run his engine room.
That doesn't count. When Spock was captain pre-TWOK, he was actually the commanding officer of the
Enterprise. He wasn't sharing it with Kirk. Kirk was commandant of the Academy at the time, and sometimes used the
Enterprise as a training vessel, but the ship only had one captain and that was Spock. As for Scotty, he wasn't promoted to "captain of engineering" until TSFS, and after that he only served under Kirk unofficially on the Genesis mission and aboard the
Bounty. It's only after the trial in TVH that things get wonky with multiple captains on the same ship.
Besides, the individual preferences of the captains in question have nothing to do with it. Starfleet isn't a hobby; officers don't get posted on the basis of what they personally want, but on the basis of where the fleet chooses to assign them. And it's anomalous for Starfleet to assign three captains to a single ship. Maybe it can be excused in Scotty's case, since "captain of engineering" doesn't seem like a command-track posting. But when Kirk was dropped back to captain, realistically he and Spock should've been assigned to command separate vessels, like in the DC Comics run where Spock was put in command of the science vessel
Surak.