Precision spectroscopy of hyperfine splitting (HFS) is a crucial tool for investigating the structure of nuclei and testing quantum electrodynamics. However, accurate theoretical predictions are hindered by two-photon exchange (TPE) effects. We propose a novel formalism that accounts for nuclear excitations and recoil in TPE, providing a model-independent description of TPE effects on HFS in light ordinary and muonic atoms. Combining our formalism with pionless effective field theory at next-to-next-to-leading order, the predicted TPE effects on HFS are 41.7(4.4)kHz and 0.117(13)meV for the 1S state in deuterium and the 2S state in muonic deuterium. These results align within 1σ and 1.3σ from recent measurements and highlight the importance of nuclear structure effects on HFS and indicate the value of more precise measurements in future experiments.