Or you could have been behaving in a manner which attracted his attention. Having several friends who are police, they are quick to notice behaviour which makes them wonder - but usually they're off duty, so don't pursue.
Or he could have been using his interaction with you to watch someone else - you were a means to an end.
But heaven forfend there was a reason other than bigotry for chosing to speak to you