At a fundamental level, the gateway must be reachable on the same layer 2 link.
With ipv4, the norm was to allocate a single block of IP addreses to a link, then to allocate the gateway an address from this block. This is not nessacerally the only possible configuration but it's the most common and most compatible.
On the other hand with IPv6 every interface has at least one link local address, it may also have other types of address. Statically configured IPv6 systems may use a global or unique-local addresses for the gateway, but automatically configured IPv6 systems will nearly always use link local addresses for the gateway.