A dirty pilot
Dust and lint can collect around the pilot assembly. That can make the flame weak or unsteady, so it may not stay in contact with the parts that sense it.
A worn thermocouple
A thermocouple senses the pilot flame and lets gas keep flowing while the flame is present. If it is worn or dirty, it can shut the gas off even when the pilot looks fine. A thermopile plays a similar role on many fireplaces.
Drafts and gas supply
Strong drafts can blow out a small flame, and a problem with the gas supply can starve it. Both are worth checking if the pilot goes out at certain times, such as on windy days.
What you can safely do
Follow the lighting steps in your owner's manual, and make sure the gas valve is in the right position. Don't take apart gas parts yourself.
If you smell gas, don't try to light anything. Leave the house and call your gas utility or 911 from outside.
