During WW1, the Germans used U-boats to blockade the British. When they started using unrestricted submarine warfare the US joined the war. Why didn't the Germans sink American ships bringing US soldiers to Europe?
They did. Or rather, they tried…?
"Unrestricted submarine warfare" meant just that: target every enemy ship, or ships you think that are (?), and try to sink it. After the American entry into the war the orders were changed from "try to avoid American ships" to "burn them all".
Things did not change dramatically upon the American declaration of war. In some respects, the German High Command was correct, and it would take between twelve to fifteen months for the American military to make a real impact on the battlefield. In other respects, they got it wrong. US industrial and economic might was unleashed, and could build and launch merchant ships and destroyers faster than German submarines could sink them. As these same submarines began sinking ships indiscriminately, they sank ships belonging to other neutrals such as Brazil, who subsequently joined the war, sending troops to fight in the trenches as well.
Having reluctantly agreed to the 1917 round of unrestricted submarine warfare, and having failed to keep the United States out of the war, Bethmann resigned his position as Chancellor in July 1917. This act sealed the victory of Hindenburg, Ludendor , and the military over the political wing of the German government. It also served as a reminder to Wilson and House that Germany had fallen from the civilized nations into a nation of warmongers.
Justin Quinn Olmstead: "The United States’ Entry into the First World War. The Role of British and German Diplomacy", Boydell Press: Woodbridge, Rochester, 2018, p 158.
The next day, 15 August 1918, U-117 resumed her mine laying operations off Fenwick Island Light. That field later claimed two victims, one damaged and the other sunk. On 29 September 1918, Minnesota struck one of those mines and suffered extensive damage. The Naval Overseas Transportation Service cargo ship Saetia entered the same field on 9 November, struck a mine, and sank.
As said above: they tried, and they tried hard. Very hard. After all, that was part of the contingency planning should the US do the for the OHL unthinkable, try to bring actual American troops to the battlefields.
But with their methods and vulnerabilities becoming known, the elements of surprise ensuring either victory or at least escape got fewer and fewer.
Not in the least because of a successful adaption: the Convoys in World War I:
Between May 1917 and the end of the war on 11 November 1918, only 154 of 16,539 vessels convoyed across the Atlantic had been sunk, of which 16 were lost through the natural perils of sea travel and a further 36 because they were stragglers.