They are detectors for explosives residue.
If an explosive device were in your bag, trace amounts of the explosive agent would likely still be around. They are most likely to come out through the airspace in the seam or through the zippers. (So they rub those areas.)
Also, the possibility is fairly high that the person who manufactured the device also handled the bag after the device was put together. (And they rub the handles).