Well, there have been times when several people with the rank captain have been on a ship (the Ent-A had Captain Kirk, Captian Spock, and Captain Scotty), but only one was technically in command, the rest would be a "Captain of Engineering" or "Captain of Science.", etc.
The word 'captain' has two meanings:
(A) A rank.
(B) The commanding officer of a ship.
There are a lot more people who have attained the rank of captain than those who command ships, and not every person who commands a ship has the rank of captain. Benjamin Sisko was the captain of the Defiant even before he was promoted to the rank of captain. So on larger ships, there can be multiple captains, but only one captain.
There can be several people with the rank of captain on a ship. Montgomery Scott held the rank of captain, as did Mr. Spock.
By long naval tradition, whoever is in command of ship is called "Captain" regardless of their rank. In the modern US Navy, the senior staff often refer to the captain as "skipper" which essentially means the same thing. They do this even if the captain of the ship is an admiral.
Each ship has a clearly defined chain-of-command, which is followed unless circumstances make doing so impractical.
Captain - 1st Officer - Mr. Spock in TOS; Rikker in TNG; and Worf or Lt. Cmdr Dax in DS9; T'Pal in ENT. 2nd Officer - (This was Dr. McCoy in TOS; however, in the later seasons of TNG, it was wither Lt. Cdr. Data or Deanna Troi (who had her own watch) Cmdr. Charles "Trip" Tucker III in ENT)
10 Feb 2016 - 11:01am MST