Broadly speaking, copyright is a reward for creative expression. A painter will generally hold copyright for their paintings, since they are making creative decisions about what and how they are painting. Similarly, a photographer will express creativity through a choice of angles, composition, lighting, exposure settings, and so on.
If a painter reproduces a scene from a photograph, it is likely that the painting will be a derivative work of the photograph – containing copyrightable aspects from both the photographer and the painter. However, it is possible that the painter does not contribute any copyrightable authorship of their own. The author of the original can generally decide whether creation of derivative works are allowed.
The subjects of a photo or of a painted portrait do not contribute any creative expression to the work, and are therefore not a copyright holder. However, there are a variety of different rights that could play a role. For example, the subject might have personality rights that could affect whether the work may be published, but that right might not weigh very strongly for public figures. The owner of the physical medium (e.g. of the painted canvas) has some rights in that object.
All of these rights and their interplay are quite jurisdiction-dependent. In the United States, the US Copyright Office has published a series of circulars and a compendium that discuss details of the US copyright system. For example, section 905 of the compendium discusses when works of visual arts (including paintings and photographs) might be copyrightable.