The number of bits in this case refers to the size of memory addresses used by the computer.
A 32-bit memory address system can point to up to 2^32 (4294967296) different memory locations (which is exactly 4GB of storage) while 64-bit can address can point upto 2^64 locations (~16 trillion GB).
Why can't a 64-bit program run on a 32-bit copy of Windows?
A 32-bit program stores the various locations where it has stored its data in 32-bits. And since it is possible to store 32-bits in 64-bits of storage, Windows will happily run the program while filling the other 32-bits of the 64-bit appropriately.
A 64-bit program on the otherhand uses 64-bits to indicate the locations. Since it is not possible to store 64-bits in a 32-bit storage without throwing away half of it, Windows will refuse to run a 64-bit program on a 32-bit computer.
Does the program have a piece of code telling Windows that it's a 64-bit program or does Windows simply fail to execute it?
Every program has a header, that tells Windows, every thing it needs to know about how to run the program including if it is a 32-bit application or a 64-bit application.
I saw a significant difference in file size of the two versions of the same program, so I think it's the code that's different. Is it possible to modify the code and make the program run?
64-bits occupy twice the amount of memory as 32-bits. That is why 64-bit programs are larger than their 32-bit counterparts.
These memory locations only make up a fraction of a program; the majority of it being instructions (which remain the same size) and stuff like text and icons. Since only the memory locations double in size, the 64-bit version of a program is only slightly larger than being double the size.
Hope this helps.