Everybody’s skin contains the ability to be a little darker or a little lighter depending on how much time they’ve spent in the sun. A lot of the time this is referred to as “getting a tan.”
People who have freckles are exactly the same -- their skin turns a little bit darker if they spend more time in the sun. The only difference is that instead of getting a little darker all over, they get a little darker just in certain small places, which give them the speckled look of having freckles!
The reason why certain people are more likely to get freckles is that a lot of the tendency to freckle is inherited. This means that freckled people usually have other people in their family who have the same trait, kind of like eye color and hair color! Some people don’t need a lot of sun to have freckles and will be freckly all the time, while others will get freckles only after spending extra time in the sun.