People are roasting this person for asking a dumb question. But I think this is a valid query and the answer is actually pretty cool.
Unfortunately, you usually get a response like this.
This is accurate. But not very explanatory. "It's how light works" just feels a bit condescending.
We need to Bill Nye this shit.
The first thing you need to know is that light competes with light. And the brightest light is always the victor.
And this phenomenon is not specific to cameras. Our eyeballs also play in the light vs light competition.
Every person with a mobile phone has already seen this effect. What happens when you look at your phone on a really sunny day?
The sun is so overwhelmingly bright that it is reflecting light off the screen that is much brighter than the light being emitted from the phone.
However, newer phones are starting to have screens that are extremely bright. Up to 3000 nits in some cases. They are able to emit light brighter than the sun's reflection.
What happens to our eyes when we go outside on a sunny day?
Our pupils get as small as they possibly can. Smaller pupils let in a lot less light. And when they are that contracted, we can only register really really bright things.
But if we are in the dark, our pupils get super big. They allow in a bunch more light. And after we adjust to the dark, we can see really really dim things.
If our pupils stayed contracted and we looked at a starry sky, it would be as blank as the phone screen on a sunny day. You can even test this with an eye patch. Go into a very bright room and keep one eye covered for about 20 minutes. Then go outside and look at the sky with each eye. One eye will see stars and the other will not.
And this should give you a clue as to how light pollution works. Light bounces off stuff in the atmosphere. And when a city shoots a bunch of light upward, that light reflects back down and is much brighter than the stars.
The brightest light always wins.
Most stars are just incredibly dim. You need to be in a very dark environment in order to see them shine. You need them bigass pupils fully activated. And cameras need either a very large aperture (lens pupils), or a very long time interval to see them.
The sun is so so soooo bright. Many thousands of times brighter than distant stars. And the moon is also very bright. Especially if you are on or near the surface. The properties of moon dust, the regolith, are a near perfect diffuse reflector. Which is why astronauts struggled to see and photograph stars during their moon excursions.
If they opened up their camera apertures and did a long exposure, they'd just get a blank white frame.
There are dozens of photos in which that exact thing happened.
This is exactly what happens if you accidentally shine a flashlight directly into your eyes.
But if we ever have a moon mission during lunar night, those astronauts are in for a starry treat. They won't have any atmosphere to absorb starlight. So they'll be able to see the Milky Way, in all its glory, with just their naked eyes.