In "The Deadly Years" when Commodore Stocker takes command of the ship, it's only because Kirk has become incapable of command. It's a desperate situation that leads to the Commodore taking action (although he's obviously not a starship commander by trade).
Yet, "The Doomsday Machine" and "The Ultimate Computer" present us with Commodores who are seemingly in actual regular command of their ships: Commodore Decker of the USS Constellation, and Commodore Wesley of the USS Lexington.
We might excuse Wesley as being another unique situation, as they're testing out the capabilities of the M-5 in a battle scenario. Maybe he's only the temporary commander of the Lexington for the purposes of that particular test run.
On the other hand, the script of "The Doomsday Machine" basically assumes that Decker is the proper master of Constellation, that he is
the captain except for his rank. Unless we are to assume that the Constellation's own captain died and Decker (like Stocker) simply happened to be on-board and took command?
What's the real-life protocol in these situations? Was it ever common in the real navy for a ship's regular "captain" to actually be a commodore?