Mine did that a while back, It would get stuck in and then out and vice versa. I ended up just relacing the drive, the motor on the drive had gone bad, supposedlly.
if its a newer comp or hard drive there could be a few different problems but if its an old comp or drive then it most likely is just worn out and needs to be replaced which is extremly cheap nowadays.