Otto von Bismarck, the leading German statesman of the 19th century, once joked, “There is a Providence that protects idiots, drunkards, children, and the US of America.” He said this not because the Americans were a great concern for him - his main interest in the US was trade -, but as the architect of the first unified German state, he was setting the tone for what two generations of German nationals would feel about America’s apparent invulnerability. It would always be better, thus, to keep America away from Germany's business.
Nonetheless, during the two major wars of the 20th century, America and Germany did indeed clash against each other, and in both cases, American entry into the war was a decisive factor in the defeat of the Germans. Germany had a good reason for desiring the non-interference of the American colossus: with a declining British Empire, and the rest of Europe mired in a diplomatic labyrinth, America seemed to be the only nation with the capacity to tip the scales in a major war.
On both occasions, Germany hoped to wage a proxy war against an undeclared enemy. In World War I, Germany planned an invasion from Mexico not once but on several occasions, one of them with a formal invitation to the president of Mexico to lead it. This would have been a German-Mexican coalition that, if successful, would have rewarded Mexico with part of the territories lost in 1847, namely Texas, Arizona, and New Mexico. To be sure, the Kaiser knew that Mexico had no chance of winning that war, even with German aid, nor of regaining its lost territory, but the German Empire did not really care about Mexico, nor was expecting a Mexican victory. Germany only needed to buy more time, enough to defeat America’s European allies so that when the US succeeded in subduing the Mexicans, it would have to negotiate with a victorious Germany.