This problem can occur if the lens detected an obstruction.
Sometimes grit or dirt can get into the lens mechanism and cause this to happen.
It only takes something as small as a grain of sand.
Try cleaning around the lens with a soft brush, or spray it with a can of compressed air to help clean it.
If that doesn't work then the camera will need to be taken to have the lens mechanism cleaned and repaired.