This statement is only partially true. Germany did have something to do with this, but it was not the sole cause of either the expansion or the contraction.

Germany can be seen as responsible for the expansion because German competition helped to give Britain an incentive to expand. As Germany tried to get more of an empire in Africa, the British had a serious motive to expand their own formal empire. They wanted to enlarge their empire to prevent Germany from taking control of more of Africa. Of course, this was caused as much by Britain's desire to control Africa and its wealth as by Germany's actions.

The major way in which Germany caused a contraction of the empire was by starting WWII. WWII was the main cause of Britain's need to contract. WWII depleted Britain's resources and made it much less able to continue to have an empire.

In these ways, Germany's actions helped to cause Britain to want to expand its empire in Africa and, later, to need to contract its empire around the world.