I need to find a good source to help explain it, but immediately after the war, there was a mass migration in Europe. Germans being run out of other countries, and people brought to Germany or other countries going back to their own. The numbers and visuals were pretty staggering. And a lot of Germans were harassed and executed along the way. And I don't just mean German soldiers, but civilians or even German speaking people who had nothing to do with the war.
Germans didn't want to live under Soviet occupation & rule.
Redefined borders of Poland and Checkoslovakia etc. meant that many traditionally German regions became parts of other ethnic states. These states had suffered under the Nazi Germany, so naturally didn't want the Germans to stay. And many Germans didn't want to stay. Sure there was terror and executions, at the very least confiscation of property.
To a smaller degree this happened everywhere in Europe: the Germans went home - also those Germans who hadn't arrived with the occupation forces or political-economic reasons. Interestingly, many civilians tied to the German presence chose to go with the Germans. As an example, when the Germans withdrew from Finland in late 1944 and early 1945, many Finns (and many of them women) went with them, some forced but many voluntarily. Think of what happened recently in Afghanistan, when the USA & allies withdrew. How many locals, also civilians, went with them.
Don't know exactly what sort of role famine played here. But Europe was in ruins, production was low, people didn't have jobs and went hungry. I'd guess the food logistics were better in the western allies occupied Germany, and people moved after food.
This is common knowledge in Europe, taught in schools. I'd bet you will find lots of info in the web (tried Wikipedia?), but eventually you would want to read a couple of books - overarching analysis as well as memoirs.
-Z