If the third and the fourth gnome would wear the same color, then the second gnome could at once conclude which hat he carries. Since this is not the current case, the second gnome does not know which hat he carries. He will not say anything. Therefore the third gnome can conclude that he necessarily should wear the color opposite to the gnome in front of him.
The third gnome is therefore the first to figure out.