TL;DR: He was able to move in sand without skidding because there was much more to some versions of BB-8 than we see onscreen.

One version of BB-8 has a trolley attached to give him traction, and moved across a hard surface covered with a thin layer of sand, rather than across loose sand; another version of BB-8 is pushed from behind by a puppeteer.

Note: All photos are screencaps from the behind-the-scenes featurette Secrets of The Force Awakens: A Cinematic Journey

Different versions of BB-8:

We can finally answer this question, thanks to the bonus materials on the newly released home video edition of The Force Awakens.

There are several versions of BB-8. At least one of these is a functional remote controlled device, but it seems that the functional version was not used as-is when BB-8 has to move over sand.

We came up with seven versions for the film — three main ones and some variations.

- Josh Lee

"Trike" version:

Trike version of BB-8, with the trolley mounted behind his body

This model of BB-8 has a wheeled grey cart or trolley attached, either in front of his body or behind it; Josh Lee calls this BB-8 the "trike" - short for "tricycle". The trolley is designed to give him some more traction.

We built the trikes because we needed a stable driving version. We motorized the ball and had the head move around on top by means of a curved track system. Motorized castors on the back allowed us to steer it. That version could go over pretty much any terrain. The only thing that defeated it was deep, very fine sand.

- Josh Lee

In the behind-the-scenes featurette Secrets of The Force Awakens: A Cinematic Journey, we can see that in at least one scene, he isn't moving over a dune of loose sand - he is actually rolling over a thin layer of sand spread over a hard surface, perhaps a board.

Trike version of BB-8, with the trolley mounted in front of his body - note the sand-covered board he is rolling across

"Rod Puppet" version:

Rod puppet version of BB-8 in the studio

One of the puppeteers who worked with BB-8 described this version as a "rod puppet", because it is manipulated via two articulated poles wrapped in green screen material and attached to his back. This version is the one used in the scene where we see BB-8 speeding across the desert (the footage of which was used in the early trailers).

And then there was the puppet, which had an axle going through the ball, rods coming out, and a track system for the head. A puppeteer in a blue or green suit would hold the rods, and have very fine control over the head and ball.

- Josh Lee

In short, this version of BB-8 can move across the sand without skidding because there is a puppeteer (also wrapped in green screen material) pushing him from behind.

These photos show the filming of the scene in question:

And these photos show the filming of the scene in which Rey first meets BB-8:

Filming BB-8's town scenes: