Many modern devices, such as smartphones, tablets, and laptops, are equipped with ambient light sensors. These sensors detect the level of ambient light in the environment and adjust the screen brightness accordingly. When you're in bright sunlight, the sensor may interpret the high light intensity as an indication that the screen should be dimmed to improve visibility and reduce glare. After a few minutes, the sensor may reevaluate the lighting conditions and adjust the brightness back to normal.

Your phone has automatic thermal dimming. When the internal temperature crosses a safe limit, iOS/Android forces the display brightness down, no matter what the slider says. The brightness control still shows “max,” but the phone is quietly overruling you—like a parent taking away car keys.

My experience says this is purely caused by some third-party app that you may have installed.
I am not aware of the ambient temperature in which you are using the iPhone. However --> Keeping iPhone, iPad, and iPod touch within acceptable ...
Store the device where the temperature is between -20º and 45º C (-4º to 113º F). Don’t leave the device in your car, because temperatures in parked cars can exceed this range.
Use iOS devices where the ambient temperature is between 0º and 35º C (32º to 95º F). Low- or high-temperature conditions might cause the device to change its behavior to regulate its temperature. Using an iOS device in very cold conditions outside of its operating range might temporarily shorten battery life and could cause the device to turn off. Battery life will return to normal when you bring the device back to higher ambient temperatures. Using an iOS device in very hot conditions can permanently shorten battery life.