Because like a submarine or probably any other naval vessel, not everyone sleeps at the same time.
I took a tour through an old decommissioned diesel submarine a few years ago, and they only had enough beds for a third of the crew, since a third was always manning the controls, and the last third was doing maintenance.