Firewalls are used to control the flow of traffic to a network. Firewalls can filter traffic by port number. This is often called OSI Layer 4 filtering. Modern firewalls can also filter based on the application. Additionally, firewalls may be able to encrypt traffic into and out of the network to protect your traffic between sites. Firewalls can act as a proxy by sitting in the middle of the communication. A client can request a website which is sent to the firewall. The proxy firewall then makes the request to the website, receives and checks the response, and then sends the traffic back to the originating requestor client.
Most firewalls can be used as a router. If it can, then it is called a layer 3 device. These firewall routers can sit at the edge of the network and can do routing and network address translation based on the routing engine inside the firewall.