This is a common way to install a 24V low-voltage transformer. These are used for HVAC thermostats, doorbells, garage door opener controls, and other "control" applications. (For instance, if you're hooking up a Nest thermostat and looking for the "C" wire, it's one of those. The other is the "R".)
Here, the transformer is part of a junction box cover plate. The 120/240V mains-wiring parts of the transformer connection are made behind the cover plate, i.e. Inside the junction box where code requires they be made. The 24VAC is on the two exposed terminals. This conforms with NEC requirements that low-voltage wiring not be run in the same raceways as mains wiring.
This installation is improper because the 24V power is run back into the conduit with mains wiring. It should travel the house in common thermostat cable, or at least, in its own conduit.
Also, this transformer/cover plate was "hacked" onto a box that is not the correct size for the cover plate. This may not be done unless the manufacturer has asked UL to list the product to be used this way. Which may be so... since the screw-holes in use look like original equipment.