Firewalls operate at the network level by inspecting packet headers in incoming and outgoing traffic. They compare this information against predefined rules to identify suspicious activity, such as malicious packets or unauthorized connections. If a packet violates the security policy, the firewall blocks it, preventing it from entering or leaving the network.