Sometimes Mail.app doesn't automatically apply rules, although all rules are active

What i did was to delete all the rules. Quit Mail. Restart mail. Create and apply rules again.

Alternatively, you can right click on a particular email, and choose apply rules (if there are rules already configured, of course).