Actually they could have touched the wires as long as they touched only one and nothing which was earthed, but that might be pretty complicated to learn by trial and error, especially if error often means death.
Isn't it pretty unique to learn from seeing? My cat certainly doesn't understand "monkey see, monkey do". In this case it's about literal monkeys of course, but I'm not even sure all of them have this capacity. Probably also some birds and dolphins and such could learn this way, but not most animals with 'friends' (or late friends)