Mars does not have a single unified magnetic field like Earth. It has smaller, more fractured fields which cover the planet and have different intensities and polarities. The absence of magnetic protection allows the supersonic solar wind flow to directly interact with the Martian ionosphere.
The Sun constantly emits high-energy photons (gamma rays) and when one of these photons enters the atmosphere of Mars, it can crash into a molecule, knocking loose an electron and turning it into an ion. These ions can then crash into other molecules and fling atoms everywhere. Some of these atoms can be knocked, or sputtered, into space, causing atmospheric loss. The amount of ionization in the ionosphere varies greatly with the amount of radiation received from the Sun. When the velocity of the solar wind increases, the Martian ionosphere is compressed and the ionopause (a boundary layer between the ionosphere and the solar wind) is displaced to lower altitudes.