You probably configured your email client to keep the messages on server (and not delete them). It remembers the kept e-mails and don’t show/download them anymore.

When you installed avast, the account details changed (because the e-mail client was redirected to avast). So, the client now doesn’t recognize the old messages kept on server (they look “new”) - so it downloaded them again.

It won’t happen again - the messages are “known” now (well, maybe when you uninstall avast and the account will be switched again, I’m not completely sure).