How do magnets work?

Yesterday afternoon, we explored how magnets work and discovered that when 2 poles are the same they repel each other and when 2 poles are opposites then they attract each other.