Loose wheel bolt?
Lucky you didn't tear up the brake shoes and lockup the brakes..
But, yes, a nut or bolt flying around inside of a contained area could have chaffed the brake magnet wire and is causing an intermittent short.
Another suspect place is most manufacturers run the brake wiring inside the axle tubes.. The wire is laying loose inside the tube and can easily rub the insulation causing an intermittent short..
Some issue with the axle tube can also break the wires inside the tube causing no connection to the other brake.
Manufacturers also do not use weather proof connectors and the wires tend to corrode inside the crimps making for poor or intermittent connections.
Check the wheel where you found the bolt loose, make sure the magnet wire is not damaged.
Check and verify all of the connections at the crimp connectors.
Barring all that, you have a 2008 trailer, running all new wiring is not a bad idea and you can upgrade the wire size a couple of wire gauges, use better weather proof wire connectors and get better braking at the same time.