"The grid" keeps everything locked, more or less.
The AC mains grid is like a very very very big flywheel.
Individual alternators attached to the grid are frequency locked to it and cannot noticeably push it faster or slower.
If you apply more power to your local alternator it will slip in phase relative to grid frequency. Slip too far and you slide off the edge (90 degrees off phase absolute maximum possible, less in practice) and free run relative to mains. At that point it is a race between the impressive magnetic arc blowout breakers and alternator death. The breakers usually win. Usually.
Even a small breaker or fuse "going" - say 100 kVA, can sound like a bomb blast. Ask me how I know ;-).
If enough stations push too much or pull too much overall the whole mains frequency will slowly slip. A central control station observes overall frequency and adjusts power in overall relative to load to keep frequency somewhat stable. Mains frequency is compared to a standard long term and nudged as required. NIST is the supplier of the ultimate US reference. I recall that the need to synchronise the whole grid was removed in the last year of few.
At half time in the US Superb-Owl when 100 million US-Americans get up out of their seats and go to make a cup of coffee the power station controllers who have been waiting this moment of terror put the grid into 'go around power please' mode to take the hit. [[I'm making that up about the terror, BUT having seen the grid power plot for that occasion it is probably true]].
If you have a moderately small grid and input a significant percentage of extra energy from elsewhere via eg a DC link and then artificially make AC from the DC and pump it into the small grid , you can accidentally wave the grid too and fro in the breeze, as it were. Sicily, fed from Italy, has had this happen.