How did German universities outperform the US's and the UK's, before the 1930s?
Prior to the 1930s, Germany had some of the world's oldest and best universities. This is largely a due to historical reasons discussed in this article  

But what changed in the 1930s? Rather than ask why German Universities out performed US universities before the 1930s, perhaps a better question would be "Why did US universities out perform German universities after the 1930s?" 

I would answer that by saying the two events caused the change. First, the influx of refuge scientists prior to World War II boosted US Science (e.g., this article). Probably the most famous scientist to flee Germany to the US was Albert Einstein.

Second, the US funded science much better than Germany after World War II.  This extra funding was partially done out of fear of Soviet science and partially an artifact that the US economy was the only one not destroyed or heavily damaged by the war. (This article talks about US Science funding and provides more insight into this specific topic)

Also during the post-war period, many scientists choose to come to the US because of research opportunities. As described in the book Moon Shot, Wernher von Braun chose to surrender to the US because he knew only the US and Russia would have the resources for a space program (he surrender was part of Operation Paperclip). He chose the US because he would rather live here.

Similarly, many scientist immigrants continue to chose the US because of opportunities not available in their homelands. The NSF describes this here.