Actually, the tail light was a pretense. He stopped him because he thought he roughly matched the description of a robbery suspect from two nights prior. Which is also likely why the officer reacted so strongly to the presence of a gun and his perception that Castile was reaching for it.