We live in a 2 unit townhouse that had a flush mount ceiling light in the shared hallway. Each bulb was controlled by a switch in each flat. When we turned on our light switch one bulb lit up, when the other flat turned on their switch on the other bulb lit up. If both switches are on both bulbs lit up. Each flat has their own breaker box and each bulb was wired to their respective switch and breaker box. When our ex-tenant was here they took it upon themselves to change the fixture and now nothing works. We would like to know what type of light to buy and how to wire it to get the same results we originally had.
Any fixture with separate leads for each bulb socket exposed in the housing should do. In many cases they pairs of leads are connected together in such a way that you can clip off the ends to separate the wires. While such modification may void warranties and UL listing, it's not inherently unsafe.
This is a really strange configuration. A better way would have been to have two separate fixture but I'll y to address just returning it to the way it was.
You'll need a two bulb fixture with each bulb in it's own socket and individually wired. Then turn off both breakers to the fixture and determine which two wires from each unit control the the light. It could be a white wire and a red wire from each unit or maybe a different color than red, if in the USA. Connect the colored wire and the white wire from one unit to the colored and white wire from one of the sockets in the fixture. Do the same for the other unit and other socket. Connect any ground wires and mount the fixture. Add the bulbs and turn on the breakers.
You just need a 2-lamp fixture which provides separate neutral wires for each lamp.
Many fixtures provide only one hot and one neutral, and internally split it to the 2 lights. You don’t want that.
A few fixtures provide only one neutral as above, but give you 2 separate hot wires - that’s so you can have dim/bright control. You don’t want that either. You mustn’t use that, no matter how tempting it is!
Some fixtures provide a separate hot and neutral wire for each light bulb socket, so 2 blacks and 2 whites. That is the one you want.
You'll need to do more than mess with the fixture to fix this situation properly
Right now, the arrangement you have with the common-area fixture "split in half" and fed from breakers in both tenant panels is a violation of NEC 210.25(B):
(B) Common Area Branch Circuits. Branch circuits installed for the purpose of lighting, central alarm, signal, communications, or other purposes for public or common areas of a two-family dwelling, a multifamily dwelling, or a multi-occupancy building shall not be supplied from equipment that supplies an individual dwelling unit or tenant space.
So, you'll need to fix the underlying problem that your building has, namely that there is no electric meter or service disconnect devoted to the common area circuits, in order to have a Code-compliant light fixture in the common area.