Much of it came down to colonial and neo colonial influences. For whatever reason, Britain built the railways in South Africa to 42" gauge which is often referred to as Cape Gauge. The adjoining colonies that connected to South Africa kept the same gauge, even though Germany in South West Africa and Portugal in Mozambique and Angola would probably have chosen a metric gauge on their own. Rhodesia of course used Cape Gauge. New Zealand used Cape Gauge as well, although interestingly, Australia seems to have opted for 30" gauge.
India, for whatever reason, chose meter gauge for their narrow gauge railways and the railways in South East Asia and the African coast facing India were all built to meter gauge.
South America chose 3' gauge in most of the countries that were under US influence while those that were ex-European colonies seem to have picked meter gauge and 30" (750mm) gauge. The major exception was Ecuador which started out building the G&Q to 3' gauge but before it was completed switched to 42" gauge. British financing may have played a part here.
Michael Allen