A lot of mountain bike lights available today can be mounted on either the handlebars or a helmet. Where they are designed for just one purpose, this is usually for handlebar mounting, and it will be listed in the manufacturers guide.
Handlebar mounts will fit around most thicknesses of handlebars, with a metal or plastic bracket that screws into place. The bracket can be left on the bike, and the light removed for charging or moving between bicycles.
Helmet mounted lights will come either with a mount that attaches through one of the vents on the top of the helmet, straps into place or occasionally using velcro patches that need to be fastened to the helmet. You’ll need to check your helmet is compatible with the light mounting fixture.
It is usually possible to purchase additional or replacement brackets and fittings for the lights. Most mounts are quick release, and don’t require tools to fix or remove them.