Perhaps the law is there to keep nosy people from harassing those who check out books that said nosy people don't find appropriate. For example, sans law, a reporter or policeman or detective could find out who check out "Godless" and give more parking tickets or write editorials, or even use such information in a custody dispute.
Same comment as above re NJ and Ann Coulter.