Here are some possible reasons why this might happen.
1. Junk filtering, or a Mail rule that you created, is deleting the messages.
2. Mail is being deleted on another device that synchronizes with the same IMAP or Exchange account. The account may be accessed using both the IMAP and POP protocols, which could happen with some mail servers. POP access could cause mail to be deleted from the inbox. Make sure that no other mail client is set up to access the account with POP.
3. Someone else has access to the account and is deleting messages.
4. Mail is being redirected or filtered on the server. For instance, there are settings in the Mail web application on icloud.com to forward incoming mail and delete it after forwarding. If you've ruled out #1 and you have control over such behavior on the server, disable it and see whether there's a change.
5. Some mail servers have a setting to delete mail automatically under certain conditions. You would access that setting through the server's web interface, not through Mail.
6. In the settings for the IMAP account in Mail, the field labeled IMAP Path Prefix in the Advanced tab should be left blank unless a server administrator tells you otherwise.
7. You installed a third-party "plugin," such as "MailButler," that changes the behavior of Mail. Remove the plugin(s) according to the developers' instructions and test. If testing shows that a plugin is causing the problem, but you still want to use it, refer to its developer for support or an update.