I swear that it looks as if they spent more time doing it wrong than it would have taken to do it right. What a mess!
I beg to differ!
I'm pretty sure tacking NM to the fence was much faster than digging for UF or even pulling a proper overhead connection, and making flying splices tp plugs certainly saves on materials - no box needed, no receptacle, just an old plug, perhaps cut off some surplus cord or broken piece of electronics and some cheap tape. And wrapping wires around plug pins (which is what the splice in the garage looks like to me, I think you can see the outline of a NEMA 5-15 plug under that tape) is probably faster than nailing up a box and wiring a receptacle too.
So, yes, it's a terrible and scary hack job, but it probably was a lot faster and cheaper than doing it right.
BTW, our garden shed was wired by running an extension cord out between two courses of roof tiles, down the roof, along the fence (blocking the gate) and through a hole in the wall of the shed... at first we didn't even notice that because the whole run was overgrown with ivy.