Spam filters use algorithms to identify patterns common in spam emails, such as specific keywords, sender reputation, and unusual sending behavior.