As far as I know a sensor can't "be exposed" for a long period of time
That is wrong, you can't capture an image at an "exact monent". An image whether film or digital is formed by photons hitting a sensor over an exposure period. In the case of a film camera the photons cause chemical changes. In the case of a digital camera they create electron-hole pairs which produce electric charges on a semiconductor junction.
The exposure period on a film camera is defined by a mechanical shutter. On a digital camera it may be defined either by a mechanical shutter or electronically by the timings used to reset and readout the sensor.
The challenge with long exposures on digital sensors is that digital sensors are relatively noisy. As well as photoelectrically generated electron/hole pairs there are also thermally generated electron/hole pairs. Many cameras will perform dark frame subtraction which helps with this but doesn't entirely solve the problem. In the serious astronomy world Cryogenic CCDs are sometimes used to reduce noise but they are impractical for regular portable cameras.
Sometimes stacked exposures are also used, the main advantage of stacked exposures over a single long exposure is that you can throw out bad frames before merging. This can be very useful for removing the affects of atmospheric turbulence from images.