Replace the switch and simply test the brakes, most likely no harm done to the magnets nor the trailer other than flattening the battery if left on long enough.
These switches are exposed to the weather and DO go bad, water tends to get into them and damages the switch contacts to the point the contacts will not pass enough current to activate the brakes.
In your case water may have been creating enough of an electrical path to conduct a small amount of current across the plastic pin (kind of like a short).
Basically if you open the switch you will find nothing more than two pieces of metal which when the plastic pin is pulled will contact each other and connect the battery to the brakes.
Really simple switch but it depends on a small O ring on the pin to keep moisture out of the switch. The O ring can go bad or lose enough shape to allow moisture in..
It is a good idea to test the breakaway each time you hitch up, just takes a couple of minutes to do this but well worth it knowing that if for any reason the trailer separates the brakes will activate..