There are two main mechanisms that cause asteroids to spin. The first is as a result of collisions, which is fairly intuitive. But even in the absence of any collisions asteroids can acquire spin due to the YORP Effect (named after Yarkovsky, O'Keefe, Radzievskii, and Paddock). The idea is that if the surface is anisotropic (which is true of asteroids), then as the asteroid radiates heat, the photon pressure will be anisotropic and will start to impart a torque onto the body.