As explained on the IntelliPaat website, firewalls and anti-virus have different roles in cyber security.
A firewall can be hardware or software. It provides protection and security to a computer or network by not allowing unauthorized users to access the system. A disadvantage is that it cannot prevent internal attacks.
Anti-virus programs are software to protect against computer viruses or other forms of malware. However, it cannot check read-only files. (It may not stop all spam or advertisements, and sometimes creates "false positives" flagging authorized users.)
Since both firewalls and anti-virus have strengths and limitations, both are needed in a cyber security program.