A Gateway is used for making your network/segment/VLAN communicate with the outside network because Layer 3 devices (Routers) do not accept Broadcast. Therefore, we must have a default gateway for unicast communication with the router.
A firewall on a network secures networks from unauthorized access, either outgoing or incoming.
Network firewalls could comprise hardware components or virtual machines, e.g., Cisco ASA, Checkpoint.