How does an LM7805 voltage regulator work?
Voltage regulators achieve "stiffness" via a feedback control loop, where "stiffness" means that a large change in load current causes a small change in voltage. 

Both switching and linear regulators include a control loop (historically analog... some of the newer switchers use digital control loops) to adjust some parameter of the circuit so that the output voltage remains constant in the presence of load current changes and input voltage changes. 

In a linear regulator the circuit parameter is the pass transistor drive circuit (which produces base current for an NPN/PNP power transistor, gate voltage for a MOSFET).

In a switching regulator the circuit parameter is the duty cycle of the switching element(s).

So there's really two areas you need to understand if you want to get into the details of  how regulators work:


topology design (achieve required limits of current/voltage/etc)
control loop tuning + stability