Governors. Old fashioned governors as seen on 19th century steam engines!
Enhanced by modern oil pressure systems and spring technologies of course.
Even the old Bonanza had a constant speed prop.
Depending on the engine type, oil pressure in the propeller dome is usually pitted against spring pressure working to move the propeller pitch in the opposite direction. On most piston driven single engine installations, the spring drives the propeller to fine pitch with oil pressure used to send it to coarse pitch.
On multi-engine and turbine powered propellers, the reverse is true, the spring tends to send the propeller to coarse pitch to the point of feather (necessary on a multi-engine aircraft to minimize drag if the engine fails) while oil pressure is used to send the prop to fine pitch and even reverse pitch, depending on the engine.
Once the pitch is established, then your question
comes into importance. The governor will sense any increase or decrease in propeller RPM. Let's just use the multi/turbine propeller installation for simplicity.
As turboprop prop speed increases (momentarily for any reason), the governor senses the increase and restricts oil pressure to the prop hub. Restricting oil pressure causes an increase in prop pitch which in turn increases prop drag which slows the prop down. Remember that if the oil pressure is reduced, the spring tries to force the prop into coarser pitch. Conversely, if the prop RPM decreases (momentarily for any reason), then the governor increases oil pressure to the hub, driving the prop into finer pitch, decreasing prop drag which of course allows the prop to go faster.
The governor(s) work full time. The changes in oil pressure are miniscule but continuous. This is how the RPM is maintained at a constant.
Hope that answers some of your question!