Generally speaking, no. Police do not have to tell you why they are stopping you before asking for ID in a traffic stop, though it may be a standard practice in many areas. The officer must have a reason—i.e., probable cause—for the stop, but they are not legally required to tell you.