We don’t know yet whether Castile was one of the robbers (even though MSNBC, without conclusive proof, reports that Yenez “mistook” him for one of them). But even if it turns out he actually wasn’t, the traffic stop was indeed related to the robbery investigation, that should be obvious.
And if the LEO genuinely thought this was an "Armed robbery suspect" he should have initiated a felony traffic stop for the safety of everyone involved.