In every electrical control panel, you will see one or two 24Volts PSU ('two' in case of redundancy).
The reason behind that is to supply some piece of equipment which are working with 24Volts. Generally, these types of equipment could be whether an instrument or a contactor auxiliary coil.
As you may know, most of the Digital Input Cards of the PLCs need a 24Volts DC power on their terminals to turn on an input in the programming logic of the PLC.
The fact is that an instrument or a contactor's auxiliary coil is a Digital Input (DI). And they are switching a so-called "dry contact" and a dry contact does not have any power by itself. So we have to apply a 24 Volts power to them and after they've switched their output, they will return a 24Volts power to the DI Card of the PLC. In these cases, most of the time we will use a PSU to distribute the power between these piece of equipment.
Consider a Normally Open Pressure Switch as an example. When the pressure reaches a specific amount that is calibrated to, it will switch its output and therefore it will return the 24Volts output to a particular channel of the PLC's DI Card.
About the Output, when PLC logic turns ON an output on one of its output card channels, it actually activates a 24Volts on that channel and this 24Volts will be directly applied to a contactor's coil via this DO Card's channel.
Or in the cases which we want to switch other voltages except for 24Volts, it will be applied to a relay coil.
The Digital Output Cards will gain this voltage from its rack's backplane or its Interface Module which it is connected to. The Interface Module is also supplied by a PSU's 24Volts power. The DI card also will be supplied by its Interface Module in order to gain its internal power consumption.
Let me know in case of further questions.