According to this source, the Redmi Note 7 Pro uses an IMX586 sensor. The press release by Sony about the sensor is available here. The sensor actually has 48 megapixels instead of 12. The page actually explains the technology quite well but I'll try to make it even clearer.
Normally camera sensors have something called a Bayer filter on top of the actual "pixels", which is essentially a colored grid. This enables the sensor to measure different colors. A neat image is provided in the Wikipedia article.
The trick in this sensor is that the filter is arranged so that the red, blue and green pixels are arranged in blocks instead of the traditional configuration. (This will result in a little bit less accurate colors, see EDIT below).
This allows the sensor to use all the single-color blocks together to form bigger pixels which are more sensitive and have greater dynamic range. This is called pixel binning. The bigger blocks are then used to calculate single result pixel values, but the resolution is only 1/4 of the original, so 12 megapixels.
When shooting in daylight conditions, an algorithm calculates the values for if the bayer filter would be "normal" and so 48MP images are obtained.
(To actually answer the question in the title: they don't. Pixel binning is used to obtain more accurate values by sacrificing resolution.)
The following image is speculation on how the 48MP images are made using the modified bayer filter, seen in discussion in this thread. Sony doesn't reveal the full details on how it's actually done. It will probably result in decreased color accuracy: https://news.ycombinator.com/item?id=17601471