Why does the water heater in my new house have another small tank hanging off the side of the pipe above it?
That is an expansion tank installed on the water supply pipe to the water heater. Its purpose is to deal with thermal expansion of water as it heats up in the water heater - to prevent water pressure from getting too high. If water pressure gets high enough it can damage valves in plumbing fixtures, joints in supply pipes and even the water heater.
Thermal expansion always occurs in water heaters. Like most substances, water expands as it is heated. This happens several times a day in a water heater after some hot water has been used in the house, and cold water flowing into the water heater is heated.
Because water is non-compressible, it will increase in pressure if it doesn't have room to expand as it is heated. In the past, the expanding water in water heaters would push some water back out of the house - into the public water main, which could absorb the pressure.
But that mechanism to relieve pressure doesn't work anymore. The reason is check valves. A check valve is a one-way valve that prevents back flow of water, keeping it from flowing in the wrong direction. Check valves are installed on all connections to the public water supply now. Their purpose is to keep water from flowing back out of the house through the service pipe.
This prevents contamination that might occur in the plumbing within a house or business from contaminating the public water supply in the street. But the flip side of it is that, unless there is some other space for expansion in the system, water pressure builds rapidly in the house as the water heater heats up.
That is where expansion tanks come in. The expansion tank contains air, which is highly compressible. Expanding water from the water heater can flow into the expansion tank, where the air compresses, making room for the increased volume of water. Water pressure in the system doesn't increase significantly.
Most houses that have a check valve on the water service pipe - usually as part of a pressure-reducing valve installed just above or below the main water cutoff - do not have an expansion tank, since it wasn't required until recently. This may or may not cause excessive pressure buildup, depending on the characteristics of the plumbing in a house.
If you've noticed that washers in plumbing fixtures seem to wear out rapidly, or if water drips intermittently from the relief valve on the water heater, consult a plumber about the advisability of adding an expansion tank. The cost is relatively modest.