The reason for this is the following:
C saw B wearing a white hat.
C thinks: If I wear white, then D will see two white hats, so D can judge that he is a black hat.
As a result, D didn't say a word (D was preceded by 1 black and 1 white, so I couldn't tell what color I was, so naturally I couldn't say a word).
So C judged that he was a black hat.