The first three levels can be solved by listing the moves in order, because you can see exactly where the rocks are. The last one cannot: the rock moves every time you press Go, so there is no fixed list that always works.
That is what if is for. An if block asks a question before doing anything: is there a rock in front of me? If yes, do one thing. If no, do the other. The program stops being a fixed list and starts making decisions while it runs.
Every app on the phone you are holding is full of these. Is the battery low, is there wifi, is the password right. Same idea, bigger program.