Is the longest day of the year in a city necessarily equal in length to its longest night?
Not quite. In Mexico City, for example, the length of the longest day, calculated from sunrise to sunset, is 13 hours and 18 minutes, while the length of the longest night by this same measure is 13 hours and 3 minutes.
The reason for this is that, at any given moment, the sun is actually visible from slightly over half of the Earth's surface thanks to atmospheric refraction. In addition, there is before and after sunrise and sunset a period of twilight in which light scattered in the atmosphere continues to be visible, so that the period of true darkness is often considerably shorter than the period of daylight.