I am also using iPhone and whenever I open an email on my iPhone it automatically marks that email on Mail (iMac) as read which I belive is sync. It there any way I leave the emails as unread on iPhone and Mail (iMac) until I open the email on that particular device, like if I open an email on iPhone it doesn't mark that email as READ on iMac Mail and vice versa.
One thing you can do is to change you Gmail accounts from IMAP to POP. IMAP keeps the mail on Gmail servers, and as you've found, once you read it, it's marked as read. With POP mail, the mail is donwloaded to each device to be read and acted on.
See this for a more detailed explanation about IMAP and POP, and how to configure them for Gmail.