In the simplest case, charge controllers limit the solar power going to the batteries so they don’t overcharge. Very simple solar controllers do this with a relay that is opened after a certain battery voltage is reached.
PWM Controllers taper the current to the battery as the voltage rises through Pulse Width Modulation of the energy input. This is better for battery life as it adds a float charge to keep batteries at 100% full.
Larger solar arrays use MPPT Charge Controllers. Maximum Power Point Tracking circuits monitor solar panel current, voltage and temperature and get the maximum amount of power they can out of the solar array. This type of controller works with all voltage panels, and can accept high voltage input while charging a low voltage battery, allowing you to wire panels in series rather than parallel. MPPT controllers are more expensive, but the extra energy harvest is usually worth it.