Malware infection

If Avast was able to detect these malware files within a week of them infecting my web browser, why didn’t it just block them to prevent them from infecting in the first place? Please see attachment.