I saw two different answers. One is that an ant got zapped giving off pheromones attracting other ants. The other one is a study of attraction to magnetism in 1992 Journal of the Kansas Entomological Society titled "Attraction of Ants (Hymenoptera: Formicidae) to Electric Fields by William P. MacKay, Said Majdi, James Irving, S. Bradleigh Vinson and Carroll Messer". A more recent article is "Can Ants Eat Your Computer? Why the “crazy rasberry” ant infests electronic devices." BY SCOTT SOLOMON
MAY 20, 2008, on SLATE.