To anyone who's ever lost a tail/hearlight over a bump:
Zip ties and/or electrical tape are your best friend.
My Taillight used to fall off all the time but electrical tape holds the two halves of it together and the clip part of it is now zip tied onto my rack now and hasn't fallen off since.
I have the Quandrant headlight which I had to wrap with electrical tape to keep from falling off over bumps/crubs. Wrapped from the light to the inside of the bar mount.
cheers