This could be a lot of things. There could be blockage in the vent or the flue. Or there could be insufficient air in the space where the water heater is located. High gas pressure could blow out the pilot when the burner comes on or shuts off. On the other hand, a flow restriction in the gas line, or too-small a gas line could result in the same thing.
We think there are so many variables here that it would pay to have an expert come in and analyze it.