Get a box to put them in, remove the batteries or get something else.
The NiteRider UltraFazer 3.0 LED (available at Wiggle) has the lock-out switch to prevent accidental turning ons. This is a relatively rare feature which is crazy given that lights are invariably carried in bags.

Although that is a new feature to the model. You can send them back for a refund if you get the old model with no quibbling needed.
You should always carry two front (and rear) lights anyway.
As for the back, the basic Cateye and Smart ones seem to survive the bag experience. This is because the switch is placed close to the bracket and is not what gets squashed first. Again, two rear lights, one mounted on your bag is a very good idea.
The Cateye models deserve the IgNobel award for bike lights because you have to hold the switch down for an age of seconds for them to turn off, but for turning them on just a quick dab will do. Then you have to flick through a dozen flashing modes to get something sensible. They should have it the other way round - a three second push to turn them on, straight to the sensible flashing mode and a single push to turn them to full beam and another press to turn them off.
Anyway, the UltraFazer is affordable lighting - not the brightest, but waterproof, good side-lighting and a sensible switch.
Also worth checking at your preferred online retailer are the 'Exposure' range. These have the twist option rather than a switch to turn them on and off. These lights are also available in the better-appointed LBS and, given their price, you may want to look before you buy.