By international law, if a war ship meets a merchant ship, they are allowed to search for items that could help the enemy. If items were found the war ship could capture the merchant ship and return it to their port, or in certain cases sink the ship.
When the first modern submarines were built just prior to World War One. They were dismissed as a useful invention because they could not surface, without much risk, to search a ship, and the inside of a submarine was too cramped to hold a crew to sail the ship, once they captured it.
That changed once Germany deployed unrestricted submarine warfare in February of 1915, which said that submarines could sink any merchant ship near the British Isles. This lasted for two years until the US Lusitania, a passenger boat was sunk and many US citizens lost their lives. To avoid getting the US into the war the Germans stopped, but restarted when they had enough submarines to do the right job.