In this case,it could be either one, but I would tend to first suspect the safety valve or its sensor bulb adjustment or the pilot burner since the oven works the first time around. The thermostatic valve is giving all the signs of operating correctly. One reasonable test might be to heat up the safety valve bulb a little more with an external heat source when the oven is calling for heat but not relighting to see if that makes it work. Depending on access, it might be practical to do this with e.g. a little propane torch. If it works then, it would seem that the pilot just isn't heating the safety valve bulb sufficiently or the safety switch is insufficiently sensitive or something like that.