There are several mechanisms that make this work:
Absorption is the most common. A photon at a specific wavelength encounters an atom or molecule and its energy is absorbed. Generally speaking, the higher the wavelength, the easier it is to be absorbed by our to component parts of our atmosphere at varying altitudes and pressures. Different gases (atoms or molecules) absorb different wavelengths more efficiently. What radiation gets through is an aggregate of what is not well absorbed by N2, H2O, O2 or CO2.
Particulate radiation like alpha and beta particles are absorbed into the magnetic field via a different mechanism. Those fields (lines of force) have polarities and particle streams of their own which are overwhelming to individual particles.