Looking at this thread it's fairly obvious that there are several different issues going on here. If deleting and recreating your mail account settings are fixing this, you had a configuration error. If using or not using a VPN is fixing this, you have a networking issue. If you're having a problem with a POP account, that's something else entirely. If the problem is intermittent, it's something else again.
In my case, and I believe many others here, the issue is a bug in Mail that was introduced in iOS 18 dealing with the IMAP folder separator character.
During the initial IMAP handshake, the server tells the client which character is used to separate paths for nested mailbox folders. e.g. If you have a mailbox 'Bills' with a mailbox 'Electric' in it, the path to that folder may be '/Bills/Electric', or '\Bills\Electric', or '.Bills.Electric', using whatever separator character the server prefers. There is no standard character used, but those three are the most common.
The caveat is that whatever character is used as a folder separator, can't exist in a mailbox name, so using '\' is fairly common as it frees '/' and '.' for use in mailbox names. Unfortunately, backslashes are also commonly used as escapes, and I suspect the IMAP code in Mail had a regression where a '\' character is getting misinterpreted as an escape during the IMAP handshake, causing an error and the client to drop the connection.
I'm running several Dovecot servers, some using '\' and some using '/'. iOS Mail fails on all the ones using '\', the ones using '/' work fine. Same version of Dovecot on the same server OS, all other Dovecot configuration is identical. When the client drops the connection, it's always immediately after the initial handshake, and there are no errors in the server logs. Even with debugging turned all the way up.
Those here running their own server, I'd like to hear what your folder separator is set to. If you change it to anything else, I expect your connection problems will go away.
Note that changing the folder separator has its own risks, Dovecot recommends you never change it. If any user has a mailbox name containing the new separator, their client (and possibly your server, depending on how the mail is stored on disk) will get confused (you'll see a single mailbox turn into one nested inside another). You also may break mail filters among other things. Make this change at your own risk. If you have the means, it's safer to stand up a new server with a different separator character, and then migrate the mail to it using an IMAP client.
Ideally, of course, Apple acknowledges and fixes the bug.