Your water heater pilot light is probably not staying lit because the thermocouple has weakened or drifted out of position.
This small copper probe sits directly in the pilot flame and generates a tiny voltage that tells the gas valve it is safe to remain open; when the signal drops, the valve closes as a designed safety measure.
Cleaning the tip with fine abrasive and confirming it sits squarely in the flame sometimes restores operation, but replacement is inexpensive and usually permanent.
Other causes include a clogged pilot orifice producing a weak yellow flame, a dirty thermopile on newer models, insufficient combustion air, a blocked flue creating downdraft, a kinked pilot tube, or a failed gas control valve.
Drafts from nearby doors and dryers can also blow the flame out. Gas work carries real risk, so involve a licensed technician whenever you are uncertain.