Assalam o allaikum.
Actually, there are these two hadiths that contradict each other;
Dawud :: Book 34 : Hadith 4210. Narrated Abdullah ibn Mas'ud:
The Prophet of Allah (peace_be_upon_him) disliked ten things: Yellow
coloring, meaning khaluq, dyeing grey hair, trailing the lower
garment, wearing a gold signet-ring, a woman decking herself before
people who are not within the prohibited degrees, throwing dice, using
spells except with the Mu'awwidhatan, wearing amulets, withdrawing the
penis before the semen is discharged, in the case of a woman who is
wife or not a wife, and having intercourse with a woman who is
suckling a child; but he did not declare them to be prohibited.
The above one says the Prophet (SAWW) did not like dyeing hair. But according to the below one, this tells us to dye our hair.
Bukhari :: Book 7 :: Volume 72 :: Hadith 786. Narrated Abu Huraira :
The Prophet said, "Jews and Christians do not dye their hair so you
should do the opposite of what they do".
By reading these you Hadiths, we may conclude there might be some other context on which the Prophet (SAWW) would be saying this.
Rest ALLAH knows the best.