This is one of my pet peeves and it totally makes me cranky!
Scanning a driver's license, or even just asking for it automatically is bad policy for several reasons.
First, it is disrespectful. The store/cashier is making an a priori assumption that you are attempting to buy a product illegally. It isn't flattering to be mistaken for a young criminal.
Second, it is an ID theft nightmare. The vendor has all the info on your license now potentially tied to your purchase history, debit card, etc, with no privacy policies or guarantee of how they will handle the data. This is worse than loyalty cards, where at least you might get a discount in exchange for your personal info.
Finally, it is a policy designed to protect the store, not you or society at large. The store is simply trying to reduce its potential liability.
There is no legal requirement for you to produce an ID much less allow them to scan it. The store is not required to ask for an ID either, it isn't an airport or border crossing.
If you are obviously of age, you should not be harassed. The staff should be smart enough to recognized that you are legal. Yes, there are borderline cases. The staff should double check when there is reasonable doubt, but that should be the exception rather than the rule.
-Alex