A carrier doping by a hydrogen substitution in LaFeAsO1−x H x is known to cause two superconducting (SC) domes with the magnetic order at both end sides of the doping. In contrast, SmFeAsO1−x H x has a similar phase diagram but shows single SC dome. Here, we investigated the electronic and crystal structures for iron oxynitride LnFeAsO1−x H x (Ln = La, Sm) with the range of x = 0–0.5 by using x-ray absorption spectroscopy, x-ray emission spectroscopy, and x-ray diffraction. For both compounds, we observed that the pre-edge peaks of x-ray absorption spectra near the Fe-K edge were reduced in intensity on doping. The character arises from the weaker As–Fe hybridization with the longer As–Fe distance in the higher doped region. We can reproduce the spectra near the Fe-K edge according to the Anderson impurity model with realistic valence structures using the local-density approximation (LDA) plus dynamical mean-field theory (DMFT). For Ln = Sm, the integrated-absolute difference (IAD) analysis from x-ray Fe-Kβ emission spectra increases significantly. This is attributed to the enhancement of magnetic moment of Fe 3d electrons stemming from the localized picture in the higher doped region. A theoretical simulation implementing the self-consistent vertex-correction method reveals that the single dome superconducting phase for Ln = Sm arises from a better nesting condition in comparison with Ln = La.