I’ll start from the vent pipe’s total developed height which needs to be at least 60”/5’ measured from the top of the draft hood to its termination point (rain / wind cap doesn’t count). 48” is definitely too short and the vent pipe should be extended but I don’t think this is responsible for the pilot to go out when it gets hot.
Since your water heater is only a couple of years old it must be equipped with FVIR Safety Feature (since 2003) – “Flammable Vapor Ignition Resistant”
There are 2 components of this system:
1. flame arrestor
2. thermal cutoff switch (TCO)
In your case, both of them may be responsible for an attic installed water heater’s pilot light to go out.
A flame arrestor is located directly beneath the water heater’s burner and its function is too permit combustion air to flow up and prevent flames (in case of an accident) to escape down. There’s also a filter on the side wall of the water heater that prevents dust particles, lint, etc from contaminating combustion chamber. I don’t know if you have a power vent in your attic and how your ventilation is designed, but this filter might be contaminated with insulation particles and dust (requires periodical cleaning).
If you have a power vent and improperly balanced attic ventilation; it creates a vacuum every time it kicks in, sucks the air through the WH vent pipe / combustion chamber, creates a situation where the flame arrestor might turn off the pilot.
Thermal cutoff switch operates properly up to 115F. Ambient temperature exceeding that (120F in your attic) may activate TCO and turn off the gas supply.
Those are all safety features that might prevent a lot of accidents but at the same time they might be annoying. I would start from checking the filter (http://www.statewaterheaters.com/cust/FVIRTechBulletin.pdf
or look for your WH brand instructions), checking ventilation ports / work on lowering attic’s temperature, extend the vent pipe to at least 60”.
Let me know if this helped and if you have any other questions.