This usually means the chuck isn't tightened properly or the bit is damaged. Here's what to do. First, make sure the drill is off and the battery is removed. Insert your bit all the way into the chuck. Then, hold the outer collar of the chuck with one hand and pull the trigger briefly in the forward (drill) direction with the other. This will tighten the chuck jaws around the bit. Don't use the keyless chuck to hammer or beat on things.
If that didn't work, there could be internal damage. Before investigating, disconnect the battery pack from the tool. Check for misalignment or binding of moving parts. If the chuck itself is bent or the internal gears are damaged, the tool needs professional service. Have your power tool serviced by a qualified repair person using only identical replacement parts.
Heads up: Always remove the battery before making adjustments or changing accessories. This prevents the tool from starting accidentally.