They think the law is whatever they say it is and think nothing of violating the rights of someone exercising a constitutionally protected activity.
No, you do not agree to hand over your ID whenever asked. There are only specific situations where they can lawfully demand ID, and this is not one of them. Why do they all feel so emboldened to deny basic rights? Because they get away with it.