Public library policy: no drinks. Period. Not even in your bag.
Barnes and Noble's policy: sure, drink a smoothie, no one will say anything.
The book store faces competition which gives it an incentive to find the right policies. Further, it highly prioritizes letting customers do whatever they want so that they will be happy. To continue to exist a book store must sell a lot of books to satisfied customers.
The government libraries have a different incentive structure. They don't need to make a profit, or be run efficiently. To continue to exist a library ultimately must answer to voters (and only indirectly via electing politicians who have different library policies), not its actual users.
Further, and this should be no surprise, the library policy is part of a general attitude by the government that it should make rules to force people to do what the rule-makers see is best. And, as is frequently the case, the government is doing a poor job with its rules. Private book stores function just fine without banning drinks.