It's really hard to tell if this is sunburn. It is damage, especially the yellow/brown parts. The darker areas may be just a temporary color change (reddish - purplish), or rot (blackish). It's hard to tell from a photo). I have this happen when I move cacti from one environment to another. So if you had these outside, but it was rather cold, and you moved them inside, and it was warm, then they could get sunburned, even though it would seem that there is rather low light conditions. Maybe this plant was in a shadier environment before? Or it could have gotten 'frosted' if you left it outside till recently. Though doesn't quite look right for this as it seems to all be on one side - as if from a light source like winter sun. But frosted cacti look darker green at first, then slowly darken and die, so it could be a delayed reaction. Many Mammillaria are not very tolerant of cold (though some are extremely tolerant).
Unfortunately there is nothing to do but wait. This is permanent damage (at least the yellow/brown part) and will not reverse. But the cactus can survive, and it's scars can sometimes add 'character' to the plant.