I mean I know how to physically replace it, as I am building a PC at the moment. But I mean down the road if I want a new CPU, could I just buy a CPU with the same socket and replace it? Or is there more to it?
Most likely, that is all there is to it.
A motherboard bios will support most of the compatible cpu's available at the time of manufacture, and perhaps even more.
On occasion, a new cpu will be compatible, but the motherboard will need a bios update to support it.
The ivy bridge introduction was an example of this.
The OS, Windows, at least is very tolerant of changing cpu chips.
About the only consideration I would think about is the chipset.
If you install a non "K" intel cpu initially, and later might want an upgrade to a "K" cpu,and overclock it, then you should have bought a Z77 based motherboard.