Why does the pilot light keep going out on my natural gas boiler?
Most pilot light devices have a sensor that detects that the pilot light is lit, and will shut off the pilot gas if it doesn't detect the lit flame.

This sensor must heat up in order to detect the flame, so after you light your pilot light, keep the pilot valve depressed for 30 seconds in order to ensure the sensor heats up.  After 30 seconds, release the valve.  If the light still goes off, repeat 1 or 2 more times.

Once the light stays lit, turn the valve to the ON or OPEN position and the pilot light will stay lit.

If the light refuses to stay lit even after several minutes of hot flame hitting it, then yes, you may have a defective sensor or other part.