But what if the device contained an explosive?

Defenders have to think about multiple threats. Explosives are harder to get, conceal from certain types of scans, and are more overtly deliberate. Neither of these is a common threat but that doesn’t mean people don’t harden against low probability/ high damage events.