In this paper, we derive in a coherent manner, starting from the basic equations of evolution of a quantum mechanical system, the master equation for the density matrix of an atom interacting with a bath of perturbers (electrons, protons) and photons, in the presence of a weak magnetic field (in the domain of sensitivity to the Hanle effect: 0.1 ≲ ωLτ ≲ 10). This paper has been inspired by astrophysical purposes: the interpretation of line polarization induced by anisotropic excitation of the levels, eventually modified by the local magnetic field (the Hanle effect); the polarization can be due to scattering of the incident anisotropic radiation, as in solar prominences, or to impact polarization, as in solar flares. The physical conditions are then those of numerous astrophysical media: any directions of polarization and magnetic field, two-level atom approximation not valid, weak radiation field (so that the bare atom description is convenient), weak density of perturbers (so that the impact approximation is valid). The master equation is derived in the framework of the impact approximation, using the S-matrix formalism without perturbation development in a first step; the Hanle effect is included. The impact approximation leads to a decoupling of the interactions with the perturbers and with the radiation, which are then additive and can be treated independently. The perturbation development is introduced in a second step. The population and coherence transfer probabilities are then obtained for a polarized neutral atom interacting with collisional charged perturbers on the one hand, in the frame of the semi-classical perturbational theory, and on the other hand for a polarized atom interacting with an anisotropic and eventually polarized incident radiation. The linear polarization of the emitted radiation is studied in the following paper which is devoted to the derivation of the transfer equation for polarized radiation in the presence of a magnetic field.