Both these verses are difficult to translate. This conclusion can easily be drawn when you compare different translations of these verses. The first words are clear: if a righteous man would strike or reprimand David, he would accept that punishment or warning gratefully, as if it were sweet-smelling oil for his head. To keep upright in the midst of evil, you must be surrounded by righteous people who can warn you in time. On your own it will be difficult to remain standing. The following verses are more difficult. They probably mean this: even if the evildoers get into trouble, David will pray for them. That fits with Psalm 141:3: keep watch over the door of my lips.
Even if their corrupt leaders are thrown down from rocky cliffs and they would be able to hear David’s words, they would hear that they are sweet and full of compassion.
5 Let a righteous man strike me it is a kindness; let him rebuke me it is oil for my head; let my head not refuse it. Yet my prayer is continually against their evil deeds.