I've worked it out!!
Two utterly stupid designs were causing the problem.
Firstly, the sensor is 4:3 (easier to manufacture, or stuck in the old ways?). Yet the default is fullscreen. Set the camera to 4:3 to take the most pixels. If you want a widescreen shot, you can always trim it later. Using 16:9 or fullscreen is simply chopping off the top and bottom of the sensor, so utterly pointless. As daft as "digital zoom".
Secondly, and my old phone never did this, maybe a different camera app, I can't remember, if you change the ratio, it forgets you want high resolution and sets it back to medium. So if you change ratio, change the resolution again.
I'm now taking 50MP 4:3 photos (not that any camera other than professional ones give you what it says anyway, you have to zoom to 50% (quarter size) to make them clear).
What utter fool makes things which don't give you their full capabilities by default?
Oh my god, now I find even more stupidity. This Moto G31 has three sensors, "wide", "super wide", and "macro". There's no point in using anything but "wide", because:
1) Wide is 50MP. Superwide is 12MP. If you need a really wide shot, simply use the 50MP sensor and take a panorama.
2) Wide is 50MP. Macro is 2MP (!). If you simply move the camera back a couple of inches and take a normal shot, then crop the photo, you still get 12.5MP (quarter of the 50MP image).