Mental anguish can be worse than physical pain, because there's no quick fix. A hug a smile, soothing music (favorite tunes from a past they remember). There are medications for stress and anxiety if this is appropriate, you could discuss it with their doctor and get more options. My mother has vascular dementia and was on Aricept, it didn't improve her memory, but seemed to keep her from getting worse for a while.. Best Wishes.
sometimes I think it just may become a habit... If you are sure they are NOT in pain, try to engage them in something they enjoy. If indeed they are anxious it may somewhat appear to be pain.