And Star Trek is more modeled on the Age of Sail and Horatio Hornblower than the Army/Navy Roddenberry new in the 1960s.
In that day in age, at least according to the book sitting right next to my computer:
- The officers were often recruited by the captain or recommended to him, along with many of what we would today call the non-commissioned officers
- A good captain was expected to both recruit people he has served with in the past AND have at least a small corps of officers and men who WANTED to join him on the next mission if their schedules worked out
- Most of the officers and crew were brought only for one specific assignment/voyage/mission/war and then sent off on their merry ways as soon as the ship came home.
- Other important members of the crew worked for the ship and not the captain, to put it simply. They were permanently assigned to the ship and refitted it in port and sailed with it on missions.
In other words, Scotty being married to the Enterprise and everyone else always tagging along with Kirk would have made perfect sense if this ship was set on His Majesty's Sailing Frigate Enterprise. Heck, Sulu hanging around with Kirk until the Excelsior was ready and Chekov coming back after being dumb enough to let 300 year old terrorists steal his ship wouldn't have raised any eyebrows.