I'm learning about ARP spoofing attacks. Can a router or switch defend against ARP attacks?
Many modern routers implement arp-spoofing protection as an inbuilt feature.
As Sunny points out, old-school switches ran on Layer 2, and typically didn't analyse Layer 3 (Network Layer) whereas routers do. That said, more modern switches may incorporate functionality that you would expect in a router, and even up to Layer 7 handling QoS and Deep Packet Inspection.
Usually a switch is not intelligent enough to prevent arp poisoning. However if the traffic between two host reach the router then it can prevent arp poisoning.
See this http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst6500/ios/12-2SX/configuration/guide/book/dynarp.html