might be a bad thermostat/ gas valve assembly. I had a go out
ccasionally tank once. replaced the thermocouple and it helped but
didnt stop it altogether
Then one nite I heard water running the tank had a leak inside the
flue, spraying water out the chimney pipe.
so the water leaked a little putting out the pilot occasionally...
how old is your tank?