This depends on the specific model of water heater, but they should not be installed outside unless stated by the manufacturer. Tank heaters are almost always intended for indoor installation, partly to ensure that the water in the tank doesn’t freeze when the heater is inactive. There are many tankless heaters that can be installed outside but make sure this is possible before buying.