Yeah city is not fully a function of zip. ~I think state is though.~* I believe when multiple cities share a zip code USPS uses the larger one. Usually the wrong city will get delivered though, probably not guaranteed.
* correcting myself, some zip codes do cross state lines
Can't say anything about the US, but in Germany when more than one cities have the same zip code it's just not important because there is only one sorting center for all cities with the same zip and they just sort per street address.