Tank water heaters :  the short answer is Bradford White is the only brand I recommend currently.  AO Smith, Lochinvar, and Rheem are the 3 other brands I see the most of around here, and AO Smith (Lowes) and Rheem (Home Depot) are in a race to make the worlds most affordable water heater and they are taking shortcuts and putting out inferior products currently.  Lochinvar is also a subsidiary of AO Smith since 2006.  It is a noble cause to try and make a very affordable water heater, but I have been disappointed numerous times looking at a fresh out of the box heater from Rheem and AO Smith. they just don't last, and then the service you get on the warranty and parts is embarrassing to say the least.

Tankless is a bit more complicated as there are a lot more brands to choose from.  My 2 favorites are the Navien NPE A2 and the Rinnai RPX Sensei they are both about the same cost and are well respected brands that havn't sold out to the AO Smith conglomerate.  They both make parts pretty easy for the repair man if needed and they make a quality product that should last a long time.