The United States and other western nations occupied Western Germany in an effort to prevent the nation from rising to military power once again, like they did prior to WWII.
The plan was proposed by Joseph Stalin, arguing that if Germany rose to power a second time (like they had with the rise of Hitler between WWI & WWII), it would threaten European and international peacetime once again. The Allies agreed that they each would occupy a specific zone in the nation and administer the country until it could be reunified.
This kept Germany as a whole weak, and dependent on each occupying force for goods, which was part of the plan. By 1948, the Allies had begun unifying their sectors to help rebuild the nation, and the occupation ended around 1952, only to lead to the division of West and East Germany, and the rise of the Cold War.