The alliance between the Nazis and the USSR predates many of Nazi Germany's aggressive moves, certainly German tank and submarine crews were training at Soviet bases from the mid-30s.
The German and Soviet armed forces started friendly exchanges already right after the First World War. The western powers were unhappy with Russias premature exit from WWI, and Germany was under the strict rules of the Versailles treaty. This drove the former enemies back together again. Quite a few Germans served in the Russian army between the wars as officer or trainer or adviser. What influence this had on the grander scale of things, I can't tell you, but the contacts and mutual interest were always there.