You may have a bad sensor or thermocouple. When the water heater lights it should generate enough heat to cause the sensor to allow gas to flow. If the sensor doesn't send the message the gas shuts off.
2011 Eagle 330RLTS with just about every option.
Dodge SRW 1 ton Cummins powered.
I was born with nothing and I still have most of it left.