Right, shooting things is OK or not depending on your intent.
If you set a booby-trap, you'll find that the part of your intent that the law measures is if you intended to set the booby-trap, not why you set a booby-trap. You'll be surprised when they listen to your excuse and your claimed reason and not their heads and point out that you've simply admitted your motive and confessed!
The intent of installing an air bag inflator is to activate a life-saving device. The intent of a bobby-trap is to cause some sort of negative effect when triggered, without the need of a human to check first to verify that they have some sort of narrowly defined special right to do harm to that person. By definition a booby-trap is not self-defense; it is activated automatically. And the intent is to harm. So even if you harmed a thief, in a jurisdiction where it is allowed to do that harm to thieves, you'd still not be allowed to do this because when you set the booby-trap, you had not already identified the thief.
If somebody threatens you with bodily harm and you pepper spray them, you're committing innocent self-defense in jurisdictions that allow possession of pepper spray. If you take that same pepper spray and set it up to spray whoever cuts or otherwise damages your bike lock, you're a terrorist. It is really that simple.
What if, for example, an authorized person cuts the lock because they determine (wrongly, perhaps) that your bike was illegally parked? They owe you for the damage, but you're not allowed to attack them with a chemical. What if they're allergic? What if they have a weakened immune system and die? You're going to prison, buddy.
Like some random idiot said, "What the fuck is wrong with you?"