The gateway is a special node in a network that governs the transition between networks and grants or prevents access. With it the protocol of one network can be translated to the protocol of the other. One can imagine it like this, that for example the Internet consists of a number of individual networks. This is your own local network, the one of you internet service provider, and the networks of organizations and companies.
Each network is autonomous in itself, and the transition from one network to the next has to be regulated. Such a transition will take place from your local network to the one of your access provider, then it is passed („routed“) to the destination where your request eventually flows into the network of the company or the supplier and provokes a response.
These networks need not be all IP-based, they need not to support the same protocol for data transport or mail exchange, etc.. In order to create now the flow of data over network boundaries, the data is translated from the protocol of one network into the other.
[ A ] "Ja" -> "Ja" [ gateway ] "Yes" -> "Yes" [ B ]
For the way back of the response similar translations take place.
[ B ] "No" -> "No" [ gateway ] "Nein" -> "Nein" [ A ]
Between networks of the same networking protocol, the problem reduces to the decision, which data flows when and where. This is the task of a router. A router usially connects the local networks of individuals to the Internet.