Sometimes it’s hard to know if you need to replace your windows or if they are repairable.
In the first picture you have complete rot and your window needs to be replaced. When the rot extends under the operable or sliding section of the window, most likely the window is beyond repair. There may also be additional water damage to the framing around the window, which would need to be addressed as well.
In the second picture only the trim is rotting and needs to be replaced.This can be done by replacing the brick mold (wood trim around the window) and sill edge (wood trim under the window) with new PVC brick mold, which will never rot. Then properly seal all joints with paintable silicone.
In the third picture you can simply repair using wood epoxy. Dig out all the soft and rotten wood and fill in using a two part wood epoxy. After the epoxy is fully hardened (24 hours) it can be shaped and sanded to match the existing trim. Then simply prime and paint.