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 Ta–Ta 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 dxy, dx2−y2, and dz2 orbitals below the Fermi level. 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.