Hazel is meant to operate on files, not emails. While you can have Hazel monitor where the email messages are stored, I would highly recommend against this as manipulating those files out from underneath Mail can cause havoc.
Both Apple Mail and Gmail have their own rule systems so I'd look into using those to do what you want.