This seams to be a common problem with the 5mode models.
Ive had 2 lights come back to me (from customers) that were jumping modes.
So i just swapped them for simpler 2 mode models.
The guys who were using these, used these on road bikes where there is little shock taken up by the bike which didnt help.
Ive used these on my mtb since and find it very hard to make them change modes unintentionally and i have knackered front forks that dont really work.
As above, make sure the pill is tight and check in the tail cap,some models put a cover over the spring that might need tightened as well, then wrap some electrical tape around the battery to stop it rattling inside (or put tape inside the barrel,if you dont want to put it on the batterys).
If you need to lengthen the battery, then get some Earth magnets from DX (around 8-10mm) for a few dollars and stick these on the + end.
Ive done this and the only way it changes without me touching the switch, is by hitting the front of the light of something hard.
You should be fine using it on you’re mtb or helmet,anyway have you ever tried riding off road with it on strobe? it can be fun!!!