Pain is felt only when a nerve end is stimulated by a cut or injury.
Since hair and nails do not have nerve endings, cutting them does not produce pain. However, cells at the base of a nail and hair are living cells and have nerve endings.
So, if a nail is cut from the base or if a hair is plucked off, pain is felt.