I trust you already know why we have user and kernel mode - separation of trusted and untrusted software - so let's try to address the how. (I'm assuming a linux environment, as you're reading about the linux kernel.)
User programs can't really be trusted with low-level memory and hardware access; at best, the could overwrite one another's data, and at worst, they could damage the hardware. However, when a program just has to have access to low-level functions like memory allocation or hardware I/O, they can use a list of trusted system calls to perform their operations.
According to LINFO, the standard procedure for switching from user mode to kernel mode is to call software interrupt INT 0x80
- this assumes you're on an x86 processor. Specifically, the interrupt is thrown when a process in user mode attempts to access a privileged operation; this is illegal, and a trap (exception) is generated. Before the user process fires this interrupt, it stores in the process register (very small, very fast memory built into the processor) the system call number and any arguments to said call.
Once the user's program fires the interrupt, the kernel takes notice of it, checks the call and its argument, and then switches the mode bit (stored in the CS register) to kernel mode. The system call executes, the mode is switched back to user, and control returns to the user's program.
The operation is only possible in this context, in no small part because it's enforced by the hardware. I'm not sure if it's actually possible for a user to execute code in kernel space, but it's possible to trick the system into thinking you're root in order to access low-level hardware - that's called privilege escalation, and while such vulnerabilities and exploits are rare, they're a huge problem when they pop up.
tl;dr: User program tries to access a privileged instruction, gets blocked, and fires an interrupt requesting the kernel's help. The kernel catches it, switches the mode bit to go into kernel mode to perform the call, and then switches the bit back and returns to the user. Users shouldn't be able to execute in kernel mode, and if they can, you've got a serious problem on your hands.