usually (but not always), 64-bit OSes will support 32-bit programs, but never the other way around
a CPU will have a bus width, so if a CPU is 32-bit, that means it can handle instructions with a size of 32 1s and 0s
a 64-bit CPU can still run 32-bit instructions because it's less than its maximum bus width
however, I have also heard that 64-bit OSes also lose support for 16-bit software
a 32-bit OS or CPU can only address 4GB of RAM because 2^32 is approximately 4.3 billion (4GB)
but for the best compatibility, you'd want the CPU, OS, and programs to all be the same