Not my area, but I'll mention that both nations gave away land in exchange for recognition of sovereignty, to prevent themselves from being gobbled up whole by direct European colonialism and by White-ruled African states. Both nations, at various periods, were British Protectorates.
Swaziland's King Sobhuza went to London in 1922 in an appeal to the Privy Council to recover some of that land. It was largely unsuccessful.
Basuto/Basotho went from an independent nation to Protectorate in 1868 in exchange for territory, but three years later, it actually WAS annexed to the Cape colony. However, the "highlanders" (literally, their country is mountains) did not enjoy being administered and colonized by Cape Colony, and then fought the Basuto Gun War in rebellion, and then Basotho returned to direct British control, so that CC wouldn't steal their land any more.
Both countries became independent in the 1960s.
Real experts, please chime in!
There are a couple of reasons, and there isn't much commonality between the two. I'm going to answer based on you asking "part of the British possessions in Southern Africa", or how they stayed sovereign. It is unlikely that Swaziland would ever have been part of the Cape Colony.
Lesotho is a mountainous kingdom which does not have a lot of resources. So at least one reason must be that it is not particularly desirable territory, and is hard to conquer.
During the 1800's it was between the Boer (Orange Free State) and British possessions (Natal). Both signed a treaty with the Basotho, notwithstanding that they still had to fight for independence from Britain, and independence from the Cape Colony. So they were not completely sovereign.
For that history, take a look at the Scramble For Africa. I also want to add one thing, which is the Mfecane/difacane. At the time, a lot of tribes lost lands to the Nguni Xhosa and Zulu tribes, particularly the Zulus in Natal. During the mfecane, tribes moved into the less hospitable, more defensible mountains of what is now Lesotho. They were able to defend themselves against the Zulu (for somewhat complex reasons not just related to this). But the result is that they were certainly prepared to make a stand in Lesotho, as there was nowhere else to go.
Swaziland was more a side show after the second Boer war. Transvaal was independent, and Swaziland became a British protectorate. This limited Boer access to the coast, forcing it through British territories (don't forget that the lowveld was a malaria area, and getting to Portoguese LM was very difficult). I don't think there was ever a chance it would become part of the CC.