Hair is made up of proteins, which are dead cells. They are attached to the scalp with living cells, from where they grow. So, while getting a haircut a person does not feel pain because dead cells are being cut, but when it is pulled from scalp the living cells are also being pulled along.
