The surface of the image sensor is easily damaged, so it is protected by a glass cover. The cover glass is susceptible to accumulating dust. This happens when we dismount and mount lenses.
Now the lens projects a miniature image of the outside world onto the surface of the image sensor. The image-forming rays must transverse the protective cover glass. Should dust motes be in the path, they shadow the image sensor. The result is a black spot as you describe.
Most of the time, tiny particles cause little harm. They image, but the impairment is so small that it often goes unnoticed. They become more obvious if they are in a uniform area like blue sky etc. They show up strongly when the setting is a tiny aperture. This is because the rays are arriving nearly collimated (nearly straight on) so the dust now shadows most strongly.
Consult your camera manual or the web for best method to clean your camera’s sensor.