So my gateway or firewall will know which URL I am trying to open? - Yes. But it will not know what your IP address is, hence the anonymity. A proxy is simply another computer that exists between your computer and the internet. For example, if you type in www.google.com in your browser while your device is connected to a proxy, this is what will occur:
The browser will make a TCP packet with an HTTP GET www.google.com request (with sender address as your IP address) and sends it to the proxy server. The proxy application running on the server looks the packet and sees that it is addressed to google. It forwards the packet to google.com, changing the sender address in the TCP packet to its own. From here google does not know that it was you who is using their service, they only see the proxy server using it.
Google receives this packet from the proxy and sends the contents of its website in another series of packets to the proxy. The proxy accepts this packet and forwards it back to you. Boom.