There's a few different mental health conditions (with decent overlaps) that are being discussed here.
Fictitious disorder - in self or imposed on another. In this condition, the person knows they/the other person is not truly unwell. However they still seek medical input, for reasons that can be unclear. Its very rare. More common in women as described above or in unmarried men 30-50. There seems to be something in it about seeking caring. If 'by proxy', this is almost always someone they are in a caring role for.
The phrase "malingering" isn't a diagnosis, but refers to the above where there is an obvious benefit for doing so. For example someone suing another person after a car crash pretends to have worse injuries than they do to increase compensation.
Persistent physical symptoms/medically unexplained symptoms/somatic symptoms disorder/non epileptic seizures - all of these refer to physical symptoms which have a psychological cause. The separation from factitious disorders is that these individuals do not create or lie about symptoms consciously. They do have these symptoms, but do not realise they are originating from a psychological place. Often people with PPS have an existing physical health condition and the psychosomatic symptoms are additional to it, related to stress and distress.
Health anxiety - about yourself or someone else. Someone affected may notice physical symptoms more than others because they are so focused on worries about being unwell. They may mistake anxiety symptoms for being unwell. They feel momentarily better once checked out by a medic but then typically build anxiety about it again.
I really want to stress that 1) all the above conditions are a source or expression of great distress and 2) the other possibility is that the person has a physical health condition that is not diagnosed. Medics are not perfect and do miss things. People are thought to be anxious/somatic/fabricating who later turn out to have a physical condition that had not been identified.