A magnesium anode is better at protecting the tank compared with an aluminum anode. Meanwhile an aluminum anode is cheaper, comes with some brands of heaters, and is also suggested if the magnesium anode adds odors (it can) to the water.
Sediment including aluminum hydroxide should be drained from the tank periodically before much accumulates. Particularly for a gas water heater, a layer of sediment at the bottom can result in temperature imbalances that break up the glass lining at the bottom and shorten the life of the tank.