Come come! It is obvious that Dwarven traps, being made from DWARVEN MECHANISMS, are magic. The mechanism when it is put into place is charmed by the dwarven mechanic so that it will never strike anyone or anyTHING that is friendly to the owner of the fortress. When magic is finally added, Toady can give the sub-division of mechanics that install the traps the dwarven guardian spell "Know friend" and the dwarf would then install the trap (now it's dangerous to all, with trap installers/mechanics having reduced risk of setting it off), the enchanter skill is used to enchant the trap, and finally it is the familar "Friend or foe" discerning trap we know. This way, only civs with access to the enchantment "Know friend" can have such discerning traps in their sites. Without that enchantment, it is a simple device that goes off on whatever meets its size requirements--- so if you set it to go off on big things like trolls, it will also kill any passing horse or cow. A second enchantment would be possible as well--- "Reset", allowing the enchanting mechanic to have the trap magically reset itself over some time period, so normal NON-ENCHANTED traps don't reset witout further reseting mechanisms. There, now we have more dwarven technology and magic working together to give us very intelligent traps. If you don't have a trap enchanter, you are stuck to the basics until you do, and be careful you don't get yourself.
Seriously--- they have to be magic. After all, let's not forget that dwarves animals, like their dogs and cats pass over those traps without them going off. Wouldn't you have to train them or set the trap to not kill them? And surely those big dogs weigh in as much as a kobald thief, at least! And that isn't even addressing things like their pet horses and cows and donkeys and mules. That's animals much bigger and clumsier than dwarves OR goblins or kobolds. And if you start taming the local wildlife, you can have pet elephants and hippotomasus... and THEY don't set off your traps! But a beserking merchant's donkey or two-humped camel does? That's just pure magic.
If a trap enchanter had to take a trap mechanism into a mechanics workshop to enchant it to for "friend or foe" behavior, that would be understandable, wouldn't it? It then becomes another task involved in making a dwarven trap--- "Enchant mechanism". No big deal, that seems like it would fit with these Toady style dwarves to me.