How do power generators generate AC at a constant frequency?
Those wind turbines not only need to operate at the same frequency they also need to operate at the same phase meaning the all need to reach the peak of the sinewave voltage at the same time.

Clearly that's nigh impossible just by doing mechanical adjustments.

So how is it done ? Well, electronics of course.

The energy from the wind turbine's rotor could be converted to a DC voltage. I'm assuming wind turbines generate AC as that would be most efficient. This AC is then rectified into a DC voltage which is then converted to "mains-style" AC by means of fast switching transistors.

The electronics take care of the frequency and phase. It can just monitor the existing voltage and synchronize to that.

The same needs to be done for solar panels as these generate DC directly.

Note that the mains frequency although quite constant, is only constant on average. You might notice that a mains synchronized clock might run fast at some time but might be running on time a day later.

In the power plant they also keep a clock running on the mains frequency and if that one is running fast they know that they need to slow down for a while.