The first thing to understand about the digital outputs of the Monarco HAT is that the DOUTs are open-collector type and they work as a sink in 24V logic.

As you can see the DOUT is in fact a ground for the circuit. When the DOUT is ON, the connection to ground is made and the current flows through the relay coil (or lamp or any other load). When DOUT=OFF, there is no connection to ground and the controlled device is off, no current is flowing. That's how you can control devices in 12V or 24V logic.

Using digital outputs in 5V logic circuits

However, to make the DOUTs usable also with 5V logic, there is an internal pull-up resistor to 5V.

Therefore in 5V logic, the DOUT will work as a source but it will have reversed logic. If DOUT=OFF, no connection to ground exists and you will measure 5V at the output. If DOUT=ON, connection to ground is made and there will be 0V at the output. That's how you can control devices which use 5V logic.