In the case of U.S. submarines, "new construction" had the crew assigned several months before commissioning, sometimes at least part of the crew was assembled even before the sub was launched. These men worked along side the ship builders, acting as both helpers and additional quality control. By the time the sub was ready for sea trials, the crew was fully assembled, organized into departments and training had begun. In many cases the Navy ran training schools for many of the duties aboard submarines very near the yards where the subs were being built so that the crew of the sub under construction could spend time together while still attending specialist schools.
Because there were seldom survivors of lost submarines, the crews of lost subs never provided the basis for cadres for new construction. Experienced sailors (some with only a few war patrols under their belts) were rotated off subs that were in commission to serve as the cadre of "experienced" chiefs for new construction. Officers were treated in the same fashion.
In the Pacific, ComSubPac developed the practice of having replacement crews that took over the jobs of cleaning, repairing and maintaining subs that came in after several war patrols. These crews were also used as pools for replacements, as sailors were rotated off active subs and then used for a time on a replacement crew until their specialty was needed for a sub under construction or for a sub where injury, illness or other need caused a sailor to be replaced.
While submarine crews were relatively small by comparison to a carrier, battleship or even a destroyer, their specialization (and the need to use "volunteers") limited the Navy's ability to simply transfer or assign sailors more or less at random. In addition, the need from day 1 of a sub's sailing to have a crew with enough experience to safely dive and surface the sub meant that training, even with the crew's future sub still under construction, had to begin long before the crew could actually get aboard the new boat.
Edward F. Finch