Sounds like switch. Spray with electrical cleaner if u got some.
And bulb holders and sockets, as back wheels spary dirty water and much onto them.
Brake lights are at the higher level, with access to the bulbholders from inside the boot. So they should be in a oerfectly dry environment.
The switch is the likely culprit, and suggestions have been given already on how to diagnose this.
1 Test supply to the switch.
2 Test the output from the switch.
:thumb2
Now to make life easier,
run a wire to a small wattage 12 volt bulb, say 5 watts or less, wire this to the input of the brake light switch, and ground the other side of the bulb.
Do the same again to to output of the switch.
Run the cables so they are out of the way, then as you drive along you will notice which bulb doesn't light.
Thus pointing to the supply and possibly the fuse, or the switch, then if neither, then the rear bulb holders or bulbs ( unlikely ) or wiring to them. (See below...)
Incidentally, do you have a tow bar?
If so, it might be a broken or intermittant connection where the caravan socket is patched in.
Hope it helps,
best regards,
Rustic