Gas water heaters heat water faster and cost less per month to run, while electric water heaters cost less to buy and install and tend to last a couple of years longer. The better choice depends on the fuel line your house already has, how much hot water your household uses, and your local utility rates.
Most people replace a water heater maybe three times in their life. You do not think about the tank in the garage until the shower runs cold on a Tuesday morning. Then you have an afternoon to decide between an electric model and a gas model.
Both heat water well. They get there differently, and that difference follows you on every utility bill for the next decade. The comparison comes down to three things: what you pay upfront, what you pay every month, and how much hot water you get at once.