In addition to what
@SaltyWaffles said was the 1935
Anglo-German Naval Agreement.
The AGNA ensured that Germany would allocate precious resources to building a Royal Navy-style fleet. This helped stop the German Navy from building a large anti-commerce fleet of U-boats, light cruisers and
Panzerschiff. By the time Hitler changed his mind in 1939, four precious years had pasted and WW2 would start, Germany had neither a surface fleet large enough to challenge the RN, nor a sub fleet capable of cutting off Great Britain.
Not really. The AGNA didn't specifically limit submarine construction; it only limited the total naval tonnage Germany could build. If Hitler had decided to go with a pure commerce-raider fleet (plus some destroyers for various purposes), he would have been able to do easily by just not building big, expensive, heavy battleships/battlecruisers, heavy cruisers, light cruisers, and an aircraft carrier.
Furthermore, WW1 had showed that surface commerce raider ships ultimately couldn't make the kind of systematic, lasting impact that submarines could. Commerce raiders were, at a minimum, light cruisers--which meant significant tonnage. Light cruisers are vulnerable to even destroyers (being lightly armored), so in the face of a large battlefleet like Britain's (and even France's), light cruisers would be easy pickings if they were ever caught and run down. Heavy cruisers and battlecruisers would obviously fare better, but it'd be a case of putting many eggs in few baskets. As the Graf Spee showed, surface raiders just couldn't afford to take damage that couldn't be repaired at sea. Absent friendly ports in the regions of operation, surface raiders tend to have a highly successful but far too brief run before being sunk or fatally damaged.
While SaltyWaffles is correct that the German surface fleet was ultimately a waste of steel, oil, and men, it must be pointed out that said surface fleet was not intended to fight the Royal Navy. German naval planning at the time of the AGNA was focused on fighting France and the USSR, both much more reasonable goals. The German surface fleet quite handily outclassed the Soviet Baltic Fleet for most of the war, and while the German navy was smaller than the French much of the French battlefleet was old and obsolete.
In addition, most of the surface ships the Germans fielded during the war were, in fact, built or building at the start. Sunk costs, essentially. Why not complete and use them? That they ended up fighting the Royal Navy anyway was as much a grand strategic failure on the entire Nazi political leadership as the fault of the Kriegsmarine.
The problem is that, even assuming such strategic thinking as "peace with Britain while we wage war against France and Russia", Hitler's plan with the Kriegsmarine just didn't make any sense. War with France and Russia would be fought on land and in the air, not at sea.
Furthermore, it was Britain's blockade of Germany that proved a fatal threat in WW1. You'd think that Hitler would be smart enough to gear his navy towards the purpose of knocking Britain out of the war should it come to that. France alone wouldn't have been able to enforce a naval blockade. Plus, submarines were originally envisioned as coastal defense vessels (German submarine designs in the years leading up to WW2 were considerably longer ranged and better equipped, obviously, so they could take the fight directly to the blockade forces if need be).
The thing is, Britain's navy represented the potentially catastrophic threat, not France's. France could be knocked out of the war through land warfare and air support. Britain's navy would need to be either defeated (a pipe-dream) or circumvented (via submarines) to knock it out of the war. Being able to counter France's navy wasn't critical (and submarines could manage well enough anyway, on a defensive level); being able to counter Britain's navy
was. Hitler going around, provoking the British time and time again whilst not having any answer to such a grave threat (the Royal Navy) was
supremely stupid. But even when war with Britain
did arrive in 1939, Hitler didn't make expanding U-boat construction the top priority. He squandered much of his airforce trying to terror-bomb Britain into submission (not learning from WW1, where neither Britain nor France were cowed by such tactics). Meanwhile, Doenitz was doing real damage to the entire British war effort, but didn't have enough subs to deal decisive damage.
Russia's navy...yeah. I just don't see how that would even factor in. Historically, the only Russian warships to accomplish anything (aside from a few botched evacuation runs to besieged port cities and some fire support against besieging forces at Leningrad) were its submarines, and even that wasn't much to write home about. Ultimately, it was submarines and air attack that sank merchant ships heading for Russian ports--the one time German surface units actually sortied to attack a convoy in the region, IIRC, the battleship in question was sunk.
I mean, I could have understood if Hitler had decided having a surface navy was a waste of resources and industrial output, and had instead dumped them into tanks and aircraft--if he believed that his enemies would be France and Russia, that would make sense. Instead, he built a surface navy, replete with numerous capital ships...and then invaded France with tanks and aircraft. Then Russia...with tanks and aircraft.
Oh yeah: remember that time in WW1 when British superiority in surface combatants allowed it to run up and down the German coast, shelling significant targets with impunity, seriously threatening the German war effort? Or the time when France's navy showed that it could attempt to blockade Germany on its own? No? Me neither.