CPU starts executing instructions from firmware (BIOS or UEFI). It performs some complicated computer-specific initialisation, discovers RAM, somewhat initialises PCI-E, USB, other peripherals and finally transfers control to the user-specified code. It's either instructions located at specific address of configured disk (old BIOS computers with MBR) or just a file in FAT32 partition (UEFI).