In Star Trek: The Original Series' season 1 episode, "The Enemy Within," Mr. Spock oddly called himself "second officer" of the USS Enterprise. In "The Enemy Within," Captain Kirk is accidentally duplicated in a transporter accident. One Kirk is malevolent while the other Kirk retains his compassion, but both versions weaken without the other. Along with Leonard Nimoy inventing Spock's Vulcan nerve pinch to subdue the evil Kirk, "The Enemy Within" is the only time Spock describes himself as "second officer."
Why Spock Called Himself "Second Officer" In Star Trek: The Original Series Season 1
Star Trek Was Still Figuring Itself Out
"The Enemy Within" was the fourth episode of Star Trek: The Original Series broadcast on NBC, and, at that point, the terminology used by Gene Roddenberry's sci-fi show was still a work in progress. Star Trek hadn't yet settled on "Starfleet" as the command authority of the Starship Enterprise, and the "United Federation of Planets" was still to be coined by producer Gene L. Coon. Spock calling himself "second officer" is likely just an early error, perhaps born from the idea that Kirk was "first" since he was the Captain.
Science Officer became the preferred role for Spock because he was the scientist of Kirk's command crew.
Spock calling himself "second officer" at this early point in Star Trek's run may also be a remnant of Star Trek's original, rejected pilot, "The Cage," where Number One (Majel Barrett-Roddenberry) was the USS Enterprise's First Officer. Lieutenant Spock was the Enterprise's second officer at that point, and it may have carried over into Star Trek: The Original Series. Gradually, Science Officer became the preferred role for Spock because he was the scientist of Kirk's command crew, although the Vulcan was also First Officer.
Ambassador Spock Was Listed As "Second Officer" In His Star Trek Beyond Obituary
A Callback To Star Trek: The Original Series?
"Executive Officer" is just another term for First Officer, while "second officer" may be a sly callback to Star Trek: The Original Series' "The Enemy Within" by the Justin Lin-directed Star Trek Beyond penned by Simon Pegg and Doug Yung.
Who Are Star Trek's Other Second Officers?
Another Star Trek Legend Also Called Himself "Second Officer"
Star Trek: The Next Generation's Lt. Commander Data (Brent Spiner) referred to himself as "second officer." As Operations Officer of the USS Enterprise-D, Data was technically the second officer in Captain Jean-Luc Picard's (Patrick Stewart) bridge crew command structure, underneath First Officer Commander Will Riker (Jonathan Frakes). Data is the only Star Trek character who called himself "second officer" after Spock, and the android's terminology was, unsurprisingly, correct.
"Second officer" was an unofficial role held by several Star Trek characters. Science Officer Lt. Commander Jadzia Dax (Terry Farrell) and Strategic Operations Officer Lt. Commander Worf (Michael Dorn) could be considered Star Trek: Deep Space Nine's second officers. Lt. Tuvok (Tim Russ), Security Chief of Star Trek: Voyager, was essentially Captain Kathryn Janeway's (Kate Mulgrew) second officer. As was Chief Engineer Commander Trip Tucker (Connor Trinneer) on Star Trek: Enterprise.
The term "second officer" didn't get popularized in Star Trek after Spock and Data.
On Star Trek: The Original Series, it was Scotty (James Doohan) who was the USS Enterprise's actual second officer. As Chief Engineer, Scotty was regularly called upon to command the Enterprise when Captain Kirk and Spock weren't aboard. However, the term "second officer" didn't get popularized in Star Trek after Spock and Data, but it's generally an unspoken of, but still real, position in Starfleet.