This is how a constant speed propeller works:

https://www.boldmethod.com/learn-to-fly/aircraft-systems/how-a-constant-speed-prop-works