Rules in Mail don't work when message is read
The mailbox rules on the iMac are only executed when Mail runs on the Mac. Thus to see the effect of the rule on the iPhone you have to have loaded the email on the Mac first.

To get the rules to work for all clients you need to implement then on the server. For most servers this means using the web version of the mail and logging on to the server there and then implementing the rules there. These rules will be acted on when the server receives the email and thus before either the Mac or iPhone has a chance to look at the email.