South Africa was early in his life, and helped shape his beliefs. They were not fully formed yet.
Thomas Jefferson once proclaimed that blacks were intellectually inferior to whites. Abraham Lincoln once claimed that when the slaves were freed they should be sent back to Africa (so did Thomas Jefferson). Both men were trying to do the right thing when they expressed these beliefs, and both were reflecting conventional wisdom of their time. More importantly, both later rejected these views completely, as their own true characters helped them see past their earlier teachings. All of us have been given beliefs at an early age that we later rejected as wrong. We are ashamed of our earlier beliefs, usually.
Gandhi was educated in England at a time when science taught that white people were intellectually superior to black people, and to all other races, and that mixing of races weakened racial purity. Hitler took those views to an extreme, and they are now rejected, but at the time even Americans like Woodrow Wilson believed they were scientific and correct. So maybe Gandhi had some of these assumptions earlier in his life, especially pre-Hitler. He does not seem to have had them later, though.
I don’t know all of Gandhi’s thoughts on Africans while he was in Africa, but I do know that the man he became, and the man he was beginning to become even then, would reject any view that one individual was superior to another based on a racial or religious grouping.