Is the Library truly a branch of City Government? Or does it just use the City name? It is governed by a separate board of Directors and is funded by a Foundation.
Mayor Quimby will probably claim they have the right to ban guns because they have the right to govern their own property.
Note that the regulations didn't mention any fines or penalties other than exclusion from the property. The threat of prosecution is lame and will only occur if someone refuses to leave.
Essentially it is private property owned by a quasi-governmental body that is using the city's name.