Most military walls and other defenses, throughout history, were built to keep people out. In the case of the Berlin Wall, the goal was to keep people inside Soviet dominated eastern Europe.
Many people in eastern Europe grew to despise Soviet domination and dictatorship. Also, the promises of communism were never realized. Central planning had not brought about a significant improvement in peoples' lives. In fact, during Stalin's leadership of Russia, millions of people starved to death and many were sent to the gulags to receive brutal treatment. Often Russian political prisoners died in captivity. The same was true in China and North Korea, where millions also lost their lives to starvation and oppression.
The result of all this misery was a mass migration of people from communist european countries to the free democracies in western Europe. Once people began to realize the wealth that was being created by free market economies in the West, they fled the Soviet dominated areas. What made things even worse for the Soviet Union was that their most intelligent and skilled people where being lost to their democratic adversaries.
Therefore, in 1961, the Soviet Union authorized East Germany to build a wall to separate their country from west Germany. Orders were given that anyone caught trying to flee into the West would be shot. Many people were killed trying to cross over or under the wall in order to escape into the democratic countries.
South America is southwest of Europe.