Firewalls prevent unauthorized access to corporate networks from outside by only allowing certain connections and traffic. They inspect packets and filter them based on rules. Firewalls work with routers to relay data between networks and use different protocols like FTP. FTP uses two TCP connections - one for control and one for data transfer. When firewalls block standard FTP, passive mode is used to connect securely.