As a German, my reason for switching to English quickly was always along the lines of "oh no, they're struggling to communicate with me! I feel bad. Let's make it easier for everyone and switch to English".
This applies especially when talking to English native speakers, but, weirdly enough, also for others - I feel better when I also have to suffer by talking in a non-native language. Doesn't really make sense, I know :)
I've talked to other Germans about this a few times and many of them agreed that this was their way of thinking in these situations.
I get that this behavior can come across as condescending and I absolutely understand the frustration about it when trying to exercise one's German skills. So nowadays, when this happens (which is quite rare anyway), I try to just stick to German.
I'm a bit puzzled why people would learn German out of all languages anyway, apart from living here obviously, so I'm always happy when someone does.
Also, I obviously can't speak for the whole German population and sadly there's definitely some xenophobia to be found wherever you look.