You don't have to be actually breaking the law, the cop just has to have a reasonable suspicion that you might be.
Many, many years ago as a teenager I got stopped by an on-foot cop (I was pulling out of a fast food place). Turns out he recognized the license plate because the car (my mom's) had been stolen (for joy rides) several times before (easy to hotwire, and predating ignition locks in the steering column). I wasn't breaking any law, but the stop was justified on suspicion. Since the last name and address on my license matched the registration, of course he waved me on as soon as I'd shown them to him.