I can't speak for Germany, but in the United States practices vary. You can't just walk into the library at the University of Wisconsin, but at North Carolina State you can.
Even in the case of Wisconsin, it looks like state residents can get a membership on a reasonably cheap yearly fee. Though I didn't see it mentioned, I'd assume this would include building access during normal hours. (Though perhaps that's a bad assumption?)
Informally, I checked the websites of a handful of state universities, and all had some way for residents to obtain borrowing privileges. It's far from a comprehensive survey, and I may be wrong in my assumption that borrowing privileges would allow normal building access. Still, at first glance it seems promising.
As the other kind reply to your comment said, sometimes access to open stacks and circulating privileges are distinct. Here in Minnesota, any member of the general public can enter the open stacks of all the University of Minnesota Libraries. I can readily gain circulating privileges as a "friend of the library" for a small fee, made smaller in my case because there is discounted membership fee for being a friend of the library for members of the University of Minnesota Alumni Association.
When I lived in Washington State, I had no particular connection with U Dub, but I could also walk onto campus and walk into the library shelving areas with no problem. When I wanted to circulate books, I looked up the state administrative regulations (it helped that I was working as a lawyer, so I knew how to look those up) and found out that a state regulation basically allows most state residents to obtain circulating privileges at University of Washington libraries for the payment of a small fee. That library has a GREAT collection of materials on east Asian languages, and I circulated some of those while I was living in Washington state.
You _can_ just walk into the library at the University of Wisconsin. There is only one library on the Madison campus (Memorial Library) that requires an ID to enter. That leaves 49 other libraries on campus open to anyone.
Fair enough, I was thinking of Memorial. And, for that matter, I was thinking of one particular library at NC State which may have been for math and science only.
Nah, at NC State, D. H. Hill (the main library) is open to the public during normal hours. The "satellite libraries" are Design, Textiles, Natural Resources, and Veterinary Medicine, and I'm not sure whether those are open access or not.
I also don't know whether the new Hunt Engineering Library is going to be public access or not, but I hope it will be because it's going to be awesome.