Firewalls will protect your device from attacks coming from the outside. The main task is to allow valid network traffic to pass through so that you can enjoy your internet connection, while at the same time identifying and blocking suspicious traffic to keep you safe.
Firewalls will also have internalized program control that makes smart decisions about whether to allow programs to have access to ports or not. The known good programs will have set permissions while bad programs will be blocked right away so that users do not have to manually configure everything themselves.
Unknown programs will be monitored and analyzed. Depending on their behavior, they might be blocked by the firewall protection later on, or allowed to persist indefinitely. The objective is to reduce the number of popup queries that tend to annoy the users while keeping them safer with the right decisions.