The chemistry of the water can make a difference in how long a WH lasts. Some codes require an expansion tank in every install, but they definately are needed in some situations. They never hurt, and they can solve some problems. IF you have a 'closed' system where there's a checkvalve or a PRV in the house, then they generally are required. WHen you heat water, it expands. If the system is open, it just pushes back to the supply line. If it is a closed system, it tries to blow the system up, and expands wherever it can - blowing up hoses like a balloon, leaking out the weakest valve or seal, or popping the safety valve (the T&P valve) on the WH open to release a little bit of pressure. This pressure cycling can decrease the life of a WH and other things in the system.
The sacraficial anode is what prevents any defect in the tank from rusting out the tank...instead of the steel rusting, the anode starts to get eaten up instead. Once it is used up, the tank will go. It is an insurance policy that you have to keep renewing. How often, depends on your water. Some effectively never get used up, but others can be gone in a short time. You may need an impact wrench to remove the original one, as they can be tough and you don't want to stress the gas and water lines by turning the whole thing (and it's really hard to hold the WH!).