a) there are also a number of SQLite databases that are used by Mail to store metadata and sundry
b) Mail's IMAP handling has been notoriously buggy at times
My guess is that this particular data loss bug in Catalina stems from a combination of the IMAP implementation and the metadata storage, but since they keep playing whack-a-mole inside ~/Library/Mail, I can't offer more details.
http://mike.laiosa.org/2009/03/01/emlx.html
https://wiki.fileformat.com/email/emlx/
It doesn't seem that hard to write some more tools to manipulate them.