It doesn’t get the IP from the relay.
Syncthing performs discovery to find the addresses of other devices. Among other things it asks the discovery servers. Those may know the external IP of the other device, and you can see the results on the URL Audrius linked above.
If it can’t connect directly it will, after some time, try to connect via a relay. If the relay connection succeeds we, of course, know the IP adress of the relay. We don’t know the IP of the device on the other side of the relay. It could be one of the addresses returned by the discovery, but it also may not be.