About the low temperature, I agree that you can install a thermostat and heater in the panel.
About the high temperature, 50 degr. C is high but not exceptionally high. In case that the 50 degr. is the exception rather than then norm (*), then a simpler fix than installing a cooler is to derate all equipment inside the panel, i.e. select at least one dimension larger than the nominal size for the load. The mmanufacturers often have recommendations as to how much the equipment must be derated.
I would also consider to avoid any heat-generating equipment inside the panel. Use a direct 400VAC to 24VDC PSU without the typical transformer in between. Choose sofstarters with integral bypass. Use a modern PLC, and not a legacy PLC. Etc...
*: Almost all equipment can operate at 50-60 degr. C. What happens is merely that the equipment age faster than normally. Not so important if the high temperature is an exception to the normal operation.