In the US and Canada, at least, they usually are open to the public.
In Toronto, the the UofT libraries are accessible to anybody. However, I did once get kicked out of the Law Society of Upper Canada library when I mixed up Osgoode Hall with the Osgoode Hall law school when I was doing research for a high school class, and I'm still bitter about that.