I have the very same problem. The root of all this is when one is behind a proxy - the original parts of avast work fine with proxy, but the stuff which is being added in the latest versions (including registration) is obviously programmed by less competent people who don't make it proxy compatible.
In the couple of past versions I experienced the same thing after upgrade - the service started but crashed later. I had to enable direct connection on my proxy to make the the upgrade/reinstall process work. Once I registered the key, I was able to reenable the proxy and the service kept working fine, and worked fine after reboot.
Unfortunately, now when I updated from 2018 to 2021, this workaround doesn't work anymore. I was hoping they might have fixed it, so I didn't disable the proxy first before update. The update didn't finish properly, I got exception violation in instup.exe after reboot (completely lame programming if you ask me). The service didn't work at all. So I did uninstall/install with proxy disabled, but for some reason it wiped out my registration/settings completely. Upset, I did system restore to 2018 , but that ended completely messed up, the avast UI got stuck in a loop crashing with an exception. So I uninstalled it and installed pre-2018 version again, this time it fortunately remembered my registration and settings, then I upgraded to 2021 with proxy disabled, it finished fine, and kept all the settings and even worked after reboot. But as soon I enable the proxy and reboot, the avast service crashes every time. It runs for a while whenever I try to start it, but then crashes again. So I am now about to rollback to older version and never update again unless they fix it.
I searched the internet regarding this but only found posts recommending reinstalling the avast ad nausea, eventually running special cleanup programs in between, and blaming other programs for the problem. Obviously the company refuses to see that the problem stems from their own incomplete proxy support. I doubt their QA ever tried that, because it is so trivial to reproduce that they couldn't miss it otherwise.
Ironic thing is, when I tried to fill the bug report from within avast when this happened for the first time, that didn't work at all - I had to turn the proxy off again to make it work at all. Which means that normal people who are having this problem are unable to report it at all. I reported that as well, but I am loosing my faith that the company cares at all...