The Maharz”u on this Medrish points out, based on a Medrish in Devorim (5:14), that it was in fact the people Gergashi, the son sof Canaan, who evacuated their cities and did not put up a fight. The Medrish there says that Yehoshua sent out treaties of surrender to each city. Whoever wanted to leave could leave, whoever wanted to make peace could make peace, and whoever wanted to fight could fight. The people of Gergashi got up and fled and G-D gave them Africa. With the Givonim who decided to make peace, Yehoshua made a peace treaty with them. However 31 kings came to fight with the Jews and Hashem delivered them into Yehoshua’s hands. (Click here fore Hebrew text)
The Maharz”u quotes a different Chaza”l as proof that Gergashi moved to Africa, which says that in the times of King Alexander the people of Africa demanded legal action against the Jews, claiming the Land of Israel which their forefather Canaan once lived on.
Why did Canaan really deserve to have the land named after him? It is not like they had the intention of fulfilling the will of G-D by leaving their homeland. They left because they were afraid of being annihilated by the Jewish People; and it wasn’t even all the children of Canaan who fled, as the 31 kings were also descendants of Canaan. Furthermore, the future generations who fled to Africa later tried to lay claim to the land, in the times of King Alexander. So why did Hashem reward Canaan with the naming rights?
We see from here the way Hashem executes judgment. When a good deed is done, He focuses on the action without any ramifications. The pure essence of their actions, which resulted in a positive favor to the Jewish people, even if it was just one nation out of 33, warranted a reward, in the form of having the name of The Land of Israel called Canaan throughout the Torah, and the present of the entire continent of Africa in place of their homeland.
Hashem rewards all people, Jew and non-Jews, for their good deeds. Imagine what the reward must be for doing a good deed, solely for the sake of Heaven, without any regrets?!