The colonies in North America and India were acquired in an earlier episode of imperialism during the 1700s. For example, French Canada and Ohio were acquired by Britain in the French and Indian War. British control of India was solidified by Lord Clive's victory over the French at the Battle of Plassey, although it was a couple decades later that complete control moved from the East India Company to the Crown. Both of these are during the Seven Year's War, prior to the general conflagration of the Napoleonic Wars.
From the Napoleonic Wars until about 1870, Britain acquired few new possessions. For example, even though Britain defeated Chinese forces in the Opium Wars, she acquired trading rights and the port of Hong Kong, rather than acquiring full political control over larger parts of China. But after 1870, the "scramble for Africa" was on, and Britain was the most successful contender. This is the second episode of Imperialism, in which leading figures like Cecil Rhodes play their part.
Germany was contender, but not so successful. My recollection is that it was limited to Cameroun, SouthWest Africa (Namibia), and Tanganyika (part of Tanzania).
The British Empire did not disolve following WW I. It took WW II to enervate Britain to the point were it fell apart. In this respect it is similar to the experience of Spain and Portugal, who were a battleground during the Napoleonic Wars, and who lost their Latin American possessions to independence shortly thereafter.
Imperialism is a state of being, not an act. As you know better than most, the British Empire was acquired gradually and over centuries. And the imperial sway over each of its dominions was a gradual process, not accomplished in one fell swoop. The British, French, German, Italian, Belgian, etc. move into Africa was the last act of the move to expand empires by Europeans. For the British, I contend, it was a sideshow whose motivating force as a combination of greed (see Cecil Rhodes) and humanitarian concerns (see the abolition of slavery).
You may want to read some biographies of the last Kaiser to understand how much imperial dominions meant to him in his effort to catch up with the French and especially the British.
And, while I know that the British Empire did not dissolve until after World War II, it was in the process of doing so during the inter-war period. That is when the British lost their appetite for ruling foreign lands (and for much else) and were seeking a way of withdrawing gracefully. And despite Churchills remark that he did not become the Queens First Minister to preside over the dissolution of the British Empire, this was inevitable. It was in the inter-war years that Gandhi traveled widely, not just in India and Africa but also in Europe, being received by the progressives of that era as the face of the future.