The war in the Sudan, which the British joined in 1885 is a perfect example of the confusing and often nonsensical nature of British Imperial policy.
At the time, the Sudan was a subsidiary province of Egypt, itself a part of the Ottoman Empire. However, some years before, Britain had backed a military coup that left it the true power behind the scenes in Egypt. Egypt was a valuable addition to the British Empire; Sudan was not. Thus, when war broke out in 1881, many in the British government saw it as a chance to be rid of the troublesome province. Unfortunately, not everyone agreed, and in a strange compromise, General Charles Gordon was sent to the Sudan with the conflicting orders to advise on the situation and organize an evacuation.
However, Gordon became trapped, which trapped the British government into sending forces to bail him out. Thus a number of major battles were fought by Britain to try and extract one man. It failed. Britain lost the Sudan, which it didn't want anyway.
And yet, ten years later, the British returned to the Sudan? Why? Well, that's even more complicated than why they went to war the first time. The simplest answer is that British pride had been wounded, and they wanted revenge. So, with nothing to gain, Britain again mounted a hugely expensive military undertaking that involved building a railroad across a harsh desert. More lives were lost, but the Sudan was retaken. Soon, after, the British rediscovered what they had already known - the Sudan wasn't a prize worth having.
British Imperialism, much like colonialism, wasn't a controlled policy organized by some chess mastermind. It was a random, often out-of-control idea, which through its path of destruction and rebuilding has done a huge amount to shape the world of today.