When one ant touches another, it's smelling it, and it can tell, for example, whether the other ant is a nest mate because ants cover themselves and each other, through grooming, with a layer of grease, which carries a colony-specific odor.