Nominatim PostCode Area Search


I am working with the OSM map but I can’t understand how nominatim gets the postcodes for some areas.
A lot of streets don’t have a postcode in germany and in a lot of times in the streets no buildings are tagged. But when I search the street, I get a postcode for it. Can someone explain me how the search is working?

Thanks a lot