As long as the Undo function is active (either unlimited or automatic), all changes to the picture are recorded on a step by step basis. The button "Undo backwards" allows you to retrace your steps. The longer the button is held down, the faster the stepping back.
The button "Undo forwards" recreates your alterations, again automatically if desired and with dynamically increasing speed as long as the button is held down.
For example you can completely restore a detail that you have Painted over, or check generally that an alteration really has improved the picture. If it has, then restore the alteration and carry on working. If you partially revoke an alteration and then carry on working, the revoked section is lost and replaced by the new changes.
The Undo mechanism can be likened to a magnetic tape recording. In the automatic mode the "tape" is rewound and re-recorded each time a new action is started, with normal recording the recording continues from the current position. With the "forwards/backwards" buttons you can wind forwards or backwards through this recording.