That, plus fanatically good NAT Traversal: https://tailscale.com/blog/how-nat-traversal-works/
The NAT traversal stuff is all magic that happens before the socket is given to wireguard.
I took a stab at recreating one of the diagrams here, using pikchr: https://zellyn.com/2022/02/tailscale-diagram-in-pikchr/