Crystallographic and electronic structures of Nb-, Mo-, Ta-, and W-based layered oxides, oxynitrides, and nitrides were analyzed to elucidate the structural relationship between layered oxides and nitrides consisting of octahedral and trigonal-prismatic layers. The electron density, as derived by synchrotron X-ray analysis of LiNbO2 and Ta5−x(O,N)6, showed orbital overlaps between Nb-Nb and TaTa metals in the trigonal layers. Computational calculations based on DFT exhibited that these overlaps stabilized these structures by lowering the hybridization states composed of the , 2 − 2 , and 2 orbitals below the Fermi level. The crystal structures and formation energies suggest that tuning the Fermi level through the substitutions and vacancies of the cation/anion sites determines the structural preferences of the coordination. The properties and syntheses of these compounds are briefly described. This study enhances the understanding of layered oxides, oxynitrides, and nitrides to further the development of new synthetic approaches, compounds, and applications.