If you set it up as an IMAP account then the Mail.app just reflects what's on the server. So if you delete them from the server they will also disappear from your computer. If you just want them on the computer create a local Mailbox. Mailbox -> New Mailbox, make sure you create it under 'On My Mac.' Then move the messages to that folder(s). Then you can delete them from the server. FYI, gmail by default doesn't actually delete anything, instead it moves it to your 'All Mail' folder.