A gas water heater pilot light that repeatedly goes out is almost always caused by one of four things: a faulty thermocouple, a dirty or clogged pilot orifice, a draft affecting the pilot flame, or a failing gas control valve. The thermocouple is the most common culprit, so that's the first thing worth checking before assuming anything more serious is wrong.
The thermocouple is a small metal rod that sits in the pilot flame. Its job is to sense heat and signal the gas valve that it's safe to keep gas flowing to the pilot. When it's worn out, bent away from the flame, or coated with soot, it cools down faster than it should and tells the valve to shut off the gas, even though the pilot was technically still burning. Thermocouples wear out with age and are inexpensive to replace, usually taking a homeowner comfortable with basic tools under an hour, or a plumber a short service call.
A dirty pilot orifice or pilot tube is the next most likely cause. Over time, dust, soot, or mineral deposits can partially block the tiny opening that feeds gas to the pilot flame. This starves the flame, making it small, weak, or flickering, which then fails to heat the thermocouple enough to keep the gas valve open. Cleaning the orifice with a soft brush or compressed air (never a wire, which can enlarge the hole) often solves the problem.
Drafts are a surprisingly common issue, especially in water heaters located in garages, basements with exterior doors, or utility closets near vents. Wind or air currents can blow the small pilot flame around enough that it separates from the thermocouple just long enough to trigger a shutoff. Check whether the burner compartment door and any access panels are seated properly, and look for obvious air leaks nearby.
Less often, the problem is in the gas control valve itself. This is the component that controls both the pilot and the main burner, and when the valve's internal thermocouple sensor or magnetic hold mechanism degrades, no amount of thermocouple replacement will fix it. A failing gas valve typically needs to be replaced as a unit, which is a job best left to a licensed plumber or HVAC technician, since it involves working directly with the gas supply line.
Other less common causes include a nearly empty propane tank (for propane units), a cracked or dirty pilot tube, or excess condensation dripping onto the pilot assembly during the first few weeks after installing a new, more efficient water heater.
If you've reset the pilot following the instructions on the water heater's label and it immediately goes out or won't stay lit for more than a few seconds even after holding the reset button the recommended time, that points strongly to a thermocouple or gas valve issue rather than a draft. If you smell gas at any point, don't attempt to relight the pilot - turn off the gas supply and call a licensed plumber or your gas utility immediately. For anything beyond cleaning the pilot assembly or swapping a thermocouple, it's worth having a professional diagnose and repair the unit, since gas appliances carry real safety risks when mishandled.