Because when you sleep, your muscles relax and since you're sitting down already, your head is the first one to go and your neck relaxes. But just like your body twitches when you try to fall asleep at night sometimes, the neck tries to hold the head up again, giving you an alarmed feeling and appearing as "bobbing" the head.