Your question is about DC power conversion, specifically voltage conversion, even more specifically, converting a higher DC voltage (say 12v) into a lower one (say 5v).
The first method you mention is using a resistor divider. lets say you want to convert your 12v rail to 5v. You could create a circuit like this

simulate this circuit – Schematic created using CircuitLab
Which would produce a 5v signal at the output terminals, so great, mission accomplished? As you correctly note, connecting an output load to the circuit changes it, and the voltage division ratio changes. Let's assume we connect a 500\$\Omega\$ load.

simulate this circuit
Now, we have an equivalent 250\$\Omega\$ resistor on the lower side of this divider, giving an output voltage of 3.158v. So there's a sag on the output voltage rail.
The next evolution of this design is to use some kind of electronic bias to keep the output voltage stable. Typically, this is done via a transistor held in its linear region, effectively acting as a variable resistor. Here's a simplified schematic

simulate this circuit
Here we can see the op-amp is driving the transistor, and the op-amp itself is trying to match some ratio (Y/Y+Z) of the output voltage against the reference voltage X. Since op-amps don't draw any current, voltage reference X can be something much simpler. if the input voltage changes, or the output current changes, the op-amp will change the drive of the transistor, keeping the output voltage at 5V.
The huge disadvantage of this method is that the excess voltage (12-5=7v) is dissipated in the transistor. Let's say we draw 1A from the load, we're burning 7W, which is more than we're supplying to the load!
Switching regulators such as a buck regulator work on a somewhat different principle, chopping packets of energy up and exchanging voltage for current in a much more efficient way.

simulate this circuit
As we can see, in this example, I've used a physical switch to turn on the transistor, but in reality, this is a more complicated controller which can take many forms and can include feedback from the load and line sides of the supply, current measurements, etc.. as it has a quite complicated job to time the on-off pulses of the transistor to chop the input voltage and uses the inductor to shape the pulses into higher current, lower voltage pulses which are smoothed by the capacitor. These devices can be massively more efficient than Linear regulators.
In short, Both linear and switching regulators can provide load and line compensation, but only switching regulators can do it efficiently. (there is also capacitative charge pumps but they tend to be only suitable for low current applications)