In-Universe:
From the original script1:
Suddenly Artoo whistles, makes a sharp right turn and starts
off in the direction of the rocky desert mesas. Threepio
stops and yells at him.
THREEPIO
Where are you going?
A stream of electronic noises pours forth from the small
robot.
THREEPIO
Well, I'm not going that way. It's
much too rocky. This way is much
easier.
Artoo counters with a long whistle.
THREEPIO
What makes you think there are
settlements over there?
Artoo continues to make beeping sounds.
You can see from C-3PO's next line that he his intent on looking for civilization. He is more keen on doing so by walking over the soft slopes of the dunes rather than attempting to scale shuffle-up a rock face to get there.
Out-of-Universe:
These scenes where shot in Sidi Bouhlel2.
Looking at the canyon where these scenes where shot (here) there appears to be several areas of flattened/hardened land for the crew to drive their RC robot across.
Seeing as these flattened areas are still present in more modern photography (also here), I think that it is safe to assume that these areas that R2-D2 is seen on were natural occurrences that were selected for the shoot.
I also doubt that they would have attempted to alter the desert landscape instead of just cheating a bit when they really needed to get R2-D2 rolling3.