Heat exchangers
Heat exchangers come in all types, the ones on fridges just happen to be air cooled. Industrial building chillers use water as the medium to be cooled this cold water is then pumped around the building and used in small heat exchangers in each room, the warm water then being returned to the chiller to be re-cooled, thus saving tons of refrigerant.
A similar principle can be used for chillers that are located in basements, where the condenser part of the chiller has cool water flowing around it that absorbs the heat from the condenser, this warm water is then pumped to the roof where it is cooled through evaporative cooling where by water sprayed onto a coil containing the warm water is evaporated by large fans blowing over the coil thereby cooling the water inside which is pumped back downstairs to be used again.
(cooling towers are not always used, most beer coolers just have a coil with water flowing through it that is passively air cooled then fed to the condenser of the unit indoors)
The condensers for fridges generally kick out temperatures of around 40-50ºC which would be ideal for preheating water for showers etc the problem would be the need for cooling of the evaporator when showers aren't being used, so you would need an alternate method of heat rejection when no hot water is being used (cooling tower?) so it would be possible but not practical.
Legionella is not really an issue as all the water in the heat exchanger is contained in a sealed system, the problem comes from the cooling towers which are an open system and need to be treated regularly.
The problem with evaporitive cooling is that the amount of cooling achievable is limited by two factors, the ambient temperature and the humidity of the air for cooling the cooling towers, for example, air at 25ºC and 100% humidity would only be able to cool to 25ºC as there can be no more water held in the air hence no evaporation and no extra cooling, air at 25ºC but 50% humidity may be able to cool to 20ºC (i can't remember the exact maths i'm afraid) as evaporation aids the cooling (think of wind on a wet finger)
Sorry for the lengthy post