Shellcodes are raw machine instructions executed directly by the CPU, so they must match the specific instruction set architecture.
To spawn a shell the shellcode has to make system calls to the kernel.
Because syscall numbers and the CPU registers used to pass arguments vary entirely between different operating systems and architectures, a shellcode written for 32-bit Linux will not work on 64-bit Linux or Windows.