Skin colour comes from melanin made by pigment cells in the lower epidermis. When those cells are triggered, by ultraviolet light, by heat, by inflammation after acne or a procedure, or by hormonal change, they produce more of it and the extra pigment settles unevenly. Where it settles decides how it looks and how it behaves.
Sharply bordered spots such as freckles and sun spots usually sit near the surface. Melasma is different: it appears as a broader patch with a hazy border, often across the cheeks, forehead, or upper lip, it is strongly driven by sun and heat, and pigment in it often sits at more than one depth. That is why melasma is described as managed rather than removed, and why the same brown patch can behave quite differently in two people who look the same in a photograph.