The thing the were using was a "bomb sniffer." It detects trace amounts of bomb making devices such as nitrates, fuel oil, etc. All the fun stuff you might use to bring down an airliner.
I do not know the criteria for them swabbing bags though as I carry the exact same bag with same contents when I travel (some times I get the swabb, others I don't).
If I were to guess it would be the idea of random searches (but what happens if six guys all in a row are carrying bombs in their briefcases for the same flight?????). Proof again our security systems is broke.