It's easy to forget that despite the Allies eventually having America and the U.S.S.R., which had the largest fleets for most of World War II and the Cold War, the Axis Powers actually started the war with a larger combined navy than their foes.
The largest fleet at the start of World War II was technically the British Royal Navy. But many of its ships were pre-World War I and World War I designs that were aging and outdated. The French fleet entered the war a little smaller. Germany quickly knocked it out of the war with the capture of Paris. Worse, the German-controlled Vichy French government later sent its ships against the U.S. at Casablanca.
So, the Royal Navy in 1940 had 153 modern ships ready for combat and assigned to task forces around the world. But it found itself fighting against 261 Italian and 126 German ships. On the German side, this was mostly submarines, but nearly all of them were of modern design and construction since the Kriegsmarine was rebuilt nearly from scratch after World War I.
The video below, from the World of Warships YouTube channel, illustrates how the relative size of the combatant navies shifted over the course of the war.
The British got a little breathing room thanks to America's "Destroyers for Bases" deal, allowing them to take possession of some older U.S. ships.
America, meanwhile, used the time from 1938 til Pearl Harbor to rapidly grow. According to the Navy's History and Heritage Command, the U.S. Navy went from a fleet of 380 ships (including support ships, which the video does not include) in June 1938 to 790 ships on the morning of the Pearl Harbor attacks. This growth occurred despite the U.S. sending 50 aging Navy destroyers and 10 more modern Coast Guard ships to the Royal Navy in the same period.
Those aging ships were full of defects but many saw fierce action. And one of them was turned into a fast-sailing bomb for the "Greatest Raid."
Of course, the events of 1941 caused other major changes to the balance of naval power between the alliances. Germany's surprise invasion of the Soviet Union in June 1941 drew it and its 272 major ships into the conflict. And in December, Pearl Harbor forced the U.S. into the war with its 345 major combat ships and submarines.
An important note as you watch, the video only measures major combatant ships like carriers, battleships, cruisers, destroyers, and submarines. It does not count auxiliary, smaller patrol, or mine warfare ships. Each of these fleets was actually much larger. In the case of the U.S., the 345 combatant ships were part of a 790-ship total fleet.