The most simple way to keep gnomes from rushing to reset traps is to only have the dedicated military with mechanics. If they are set to train they won't go to reset them until you remove them from the training grounds.
If you want to use mechanics you can keep any of your gnomes from running at the traps but still have a more open gate.
Traps will attack the one enemy that triggered them and wont attack again until reset.
They can still be really useful since goblin forces will try to escort goblin raiders, but since the raiders are faster they will be the first ones hit by the traps which might slow them down (as well as the ones following them) or kill them outright.
If all the goblin raiders are dead and the soldiers/ogres don't see any thing to fight they will leave.
You can also not let the gnomes have a path to the outside where the traps are, but have treasures stored behind hallways of traps to bait the raiders.
If your goal is to just kill all of the invaders a more complex trap will perform better. In general I don't make much use of traps but they do have uses until goblins start raiding in large numbers.
If you want help building any of the mechanics (gates, complex traps, and even simple trap designs)I will gladly offer it.