I have a similar problem in a new house. There is one bath that does not get above lukewarm, ever. I have a recirculation pump. I assumed it was the temperature valve, but the plumber cut the drywall and adjusted the valve to max hot. No difference. Now, I’m guessing it’s just a bad valve.
One more thing to check. I swear this happend to me. Check to make sure the in and out pipes are going in and out the proper places. The last time I had a new water heater put in, they hooked up the pipes backward, so the out water came off the bottom of the tank rather than the top (or is it the other way around?). This meant that we would get hot water for the first few minutes but after that it was only sort of warm.
The thermostat is a user adjustable dial on the side of the gas control valve. To save energy they are set low (120F or maybe less) Crank it up a bit and see if it helps.
I’ll second checking the inlet-outlet connections. There is a lot of convection happening when the burner runs, and the whole tank gets hot. Let it sit and the coolest water moves to the bottom. The outlet should be from the top of the tank, and the inlet feeds to the bottom (usually via a internal tube.)
When the new heater was installed, the installer may have assumed the old connections were correct, and copied the error.
The connections on the top of the tank are normally labeled, and you can tell the two pipes apart by feeling the temperature when you have a hot water faucet open.
Nope. They are a fairly complex valve assembly, thermocouple safety for the pilot flame, etc. My state forbids the sale of a replacement to anyone not holding a gas-fitters license, and they are only available at HVAC wholesalers.