“Cursed is Canaan; a servant of servants shall he be to his brothers” (B’reishis 9:25). Why was Canaan cursed if it was his father, Cham, who had acted inappropriately (9:22)?
B’reishis Rabbah (36:7) quotes several approaches that address this issue. Rabbi Yehudah says that Noach would have cursed Cham, since he was the one who sinned, but because G-d had already blessed him along with Noach and his other sons (9:1), Noach felt he couldn’t curse someone whom G-d had blessed, and therefore cursed Cham’s son instead. As far as why Canaan was the son of Cham whom Noach cursed, if we include some of the other quoted approaches, this can be addressed as well. For example, Rabbi Nechemya says that Canaan was cursed because he saw what his grandfather had done and told his father about it (see Maharzo); since Noach couldn’t curse Cham directly (because he was “blessed”), he cursed the son of Cham who was somewhat involved instead. Another approach brought in the Midrash to explain why Canaan was cursed instead of Cham is that Cham had prevented Noach from having a fourth son, so Noach cursed Cham’s fourth son; this could also explain why, if Noach wanted to curse Cham but couldn’t because of G-d’s blessing, he cursed Canaan instead. (Midrash HaGadol says this explicitly; baruch she’kivanti.) Ramban (9:18) says that Canaan was Cham’s oldest son, and the only one born at the time of this incident, so cursing Canaan meant cursing all of Cham’s current descendants and at least one branch of any future descendants; if Noach couldn’t curse Cham, this would have been the next best option available to him.
What these possibilities do not explain is how Canaan could suffer for his father’s sins. Seeing his grandfather in a disgraced manner and telling his father instead of covering Noach himself doesn’t seem to warrant such a harsh punishment, unless he was old enough to have realized on his own that he should have done so. (It should be noted that the language of the Midrash Tanchuma and Midrash HaGadol imply that Canaan did sin by telling his father rather than covering his grandfather himself.) However, if Cham himself would have been cursed, all of his children would have been cursed too (by extension), including Canaan, so limiting the adverse affects of the curse to just Canaan — who would have been affected anyway — isn’t as problematic. (How children can be affected by their parents’ punishment is a separate topic. See Ralbag on Sh’mos 20:5, where he compares it to children still being in exile when it was the parents’ sins that brought about the exile in the first place, and to rich parents losing their wealth whereby their children no longer benefit from it. As with so many other things, the children’s “starting point” is affected by the parents’ circumstances and choices.) Nevertheless, Radak (B’reishis 9:24) says that Noach, being a prophet, cursed Canaan knowing that he and his descendents would always be wicked.
Others (e.g. Ibn Ezra and S’fornu) say that it was really Canaan who committed the most grievous sins against Noach, not Cham. Cham may have told his brothers about the compromising situation their father had put himself in, and should have covered Noach himself instead, but Canaan overheard what his father had said, and committed far worse sins, sins deserving of Noach’s curse.
Rav Saadya Gaon (9:18, see also Midrash HaGadol) suggests that Cham was regularly referred to as “the father of Canaan.” Chizkuni (ibid) says that Canaan was conceived (inappropriately) in the ark during the flood, and born shortly afterwards, which would explain why Cham was called (apparently derogatorily) “the father of Canaan.” According to RS”G (9:25), Cham, whose nickname (“the father of Canaan”) was sometimes shortened to just “Canaan,” was the one who was cursed, not Canaan himself. He was the person Noach was referring to when he “cursed Canaan,” i.e. the father of Canaan. [This seems to also be the opinion of the third and fourth approaches quoted in B’reishis Rabbah, although Midrash Tanchuma also quotes the third approach yet says it refers to Canaan.]
Whether the curse was directed at Canaan or at Cham would seem to affect how the rest of the verse is read, as the cursed one was made “a servant of servants to his brothers.” If Canaan was cursed, his brothers would include (but not necessarily be limited to) his father’s other sons, with his uncles being explicitly included in the next two verses. If, however, Cham was the one being cursed, Shem and Yefes were the “brothers” to whom he is a “servant of servants,” without there being any indication of Canaan being a servant to Cham’s other sons (his literal brothers). Nevertheless, if Canaan was the oldest, and the only son Cham had so far, even if Canaan was the one being cursed, “his brothers” must refer to his uncles.
As far as why Noach repeated that Cham (or Canaan, if he had no brothers yet) was a servant to Shem and to Yefes if he already said he was to be “a servant of servants to his brothers” and this referred to Shem and Yefes, it could have simply been done for emphasis. It’s also possible that Noach didn’t curse Cham (or Canaan) in front of Shem and Yefes, so needed to mention the servitude to them directly.
Another possibility is that Noach was limiting the servitude by pointing out that Cham (or Canaan) was a “servant of servants,” with the second “servants” referring to Shem and Yefes. By calling Cham (or Canaan) the “servant of Shem” and the “servant of Yefes” after calling him a “servant of servants,” we are made aware that the reason he is a “servant of servants” is because Shem and Yefes are themselves servants, and must answer to a higher authority; only if they remain servants of G-d, and therefore treat their servants with dignity, is it appropriate for their “brother” to be their servant.