Defensive mimicry is the most common kind. Spiders that look like ants are less likely to be attacked by larger spiders, because ants are generally pretty aggressive prey -- and don't taste very good to their eight-legged attackers, anyway. In 2013, a PLOS ONE study found that a species of jumping spider that mimics ant appearance was less likely to be preyed upon by wasps than species that didn't mimic ants.
Predators who mimic their prey are less common, but the adaptation is delightfully devious: Because ants are aggressive and social, spiders want to do everything they can to catch them on their own. If not, they might succeed in killing their prey only to be attacked by the rest of its colony. From The Conversation:
Aggressive crab spiders typically jump on a lone unsuspecting ant and bite it. Then, in order to avoid encounters with other ants, the spider and its victim fall away on a safety line made of the spider’s silk while the venom takes effect. Others, like the ant-mimicking ground spider, use the body of their dead prey as a shield, holding it up between themselves and any other challenging ants. This tricks attacking ants into believing that the spider is just another ant, carrying a dead nest-mate away from their nest.
Mimicry isn't exclusive to ant poseurs, of course. Lots of insects have actually evolved to mimic plants as a form of camouflage, and sometimes plants even evolve to mimic insects. When it comes to avoiding predators and reproducing, just being yourself isn't always an option.