Australia, Canada, New Zealand and South Africa all became dominions of the British with their own parliaments and laws. If these countries were seen to be able to run themselves, but not allowed to be truly independent, why were they separated into different countries rather than incorporated into the United Kingdom?
I am going to speak for Canada here, but much of what I say goes for Australia, New Zealand and South Africa as well (albeit with their own unique caveats).
The short answer is that Britain wanted the benefits of empire without the drawbacks of administration. It is both difficult and expensive to manage the affairs of territories that are an ocean away, but when the only people living there are a few trappers and farmers it's doable. As Canada grew and developed, its society became more complex and its administrative needs became greater. The Canadians also agitated for home rule, even rebelling a couple times. Britain liked having a massive colony on the North American continent, but found the cost of maintaining it increasingly intolerable. Fortunately, Canada being more developed also meant it was more capable of handling its own affairs. Britain opted to devolve certain powers while maintaining others so that it could keep the best of both worlds in cost and control.
This also didn't make Canada an independent country immediately. Confederation was in 1867, but the powers the Canadian government had then were far fewer than today. Canada could not control its own foreign policy nor make changes to its constitution (among other things). Canada was more deeply tied to Britain both economically and culturally, and wanted to preserve those ties. (Most) Canadians didn't want a full break with Britain any more than the British did with Canada, even if the Canadians wanted more home rule. Canada was less an independent country than an autonomous branch of the British Empire. It was only over the next century and a bit that Canada became a fully independent country. As a concept, "Dominionship" wasn't set in stone and was subject to a lot of change. WWI saw a unique Canadian identity emerge, WWII saw increased devolution of foreign policy powers as well as an economic shift away from Britain, and finally in 1982 the ability to make constitutional changes was patriated to Canada. The label "Dominion" never changed, but the meaning of the word did.
So really, Confederation didn't make Canada an independent country so much as it smoothed over the rougher parts in the Anglo-Canadian relationship. Britain liked empire, but didn't like the cost, and fully integrating would have been massively expensive. Instead, it traded some political capital and got to keep their colony at a reduced rate. It wasn't until the 20th century under different economic and ideological conditions that Canada became truly independent.