Nazi submarines preyed on mostly unarmed civilian shipping early in the war and they were called "wolf packs" for good reason. There wasn't much opportunity for American subs in the Atlantic so most of the operations centered in the Pacific. The problem was that they were slow underwater and needed battery charging on the surface and they weren't really as effective as legend would have it.
I am not sure where to begin. First, you have to take into account combat multipliers. Let’s explain that.
Let’s say you destroy an oil tanker. Ok, that now restricts the amount of oil that the Japanese can move. That reduces the amount of Oil that they can use. It reduces the numbers of ships they can put out to sea to hunt the submarines. It’s a bit counter intuitive, but we saw it ourselves.
Patton was tearing across France. He had the momentum, and the Germans were unable to gather sufficient force to stop him. However, Patton ran out of Gas. His tanks couldn’t move. His attack stalled out because of supply. And that was just one well known example.
The same was true of the Japanese. Their ships needed fuel to move. And there was a shortage of Fuel when the war started. That shortage became even more pronounced as the war continued. The Sortie of the massed fleet for Midway for example, burned up a lot of fuel they could only risk if they could stop the raids the American Carriers were conducting. They needed to take the American Carriers off the board, because the Carriers were damaging and destroying ships and harbor facilities around the Pacific.
Take the raid at Truk. Yes, they destroyed some warships. But the biggest blow wasn’t the warships. It was the merchantmen. 32 Merchant hulls destroyed. That is thirty two ships that aren’t running supplies to the Japanese Forces on the islands. 32 ships that aren’t carrying fuel to the fleet at forward bases. Or reinforcements to better defend the islands the Japanese had taken.
Wars are fought by warships, soldiers, and Marines. Granted. However, wars are won or lost on supplies. Beans and Bullets may not be as sexy as planes and ships. But they are vital to the battle.
Even when we started to get the Battleships of Pearl Harbor repaired and back into the war, we didn’t use them. It wasn’t that we couldn’t risk them. It was that we couldn’t fuel them. We didn’t have the ships needed to transport the fuel for all the ships we did have. We could fuel either the Carrier task-forces, or the battleships, and we preferred the Carriers.
The same was true of the Japanese. Even damaging the hulls we attacked by Submarine, not sunk in other words. That damaged ship clogged up harbors, and took up resources the Japanese could ill afford to repair the ship. Like your example of warships alone, the Japanese focused on repairing their warships, and left the vital supply vessels to wait for repairs.
When Yamato set out on her suicide charge. She barely had enough fuel to reach Okinawa. She wouldn’t have enough fuel to return. From an Unsinkable ship in 1941, to a sacrificial glorious charge in 1945, impotent though it was.
Killing Merchant Hulls as they were, the Submarines were in fact having a greater effect on the war than if they had been focusing on warships alone. Because from our own experience, starving soldiers don’t fight as well as well fed and supplied troops.
Put it this way. When you destroy a supply vessel. You not only destroy the supplies on that ship right now. You prevent the next ten voyages already scheduled for that ship in the future.