Two-dimensional MX2 (M = Mo, W; X = S, Se, Te) homo- and heterostructures have attracted extensive attention in electronics and optoelectronics due to their unique structures and properties. In this work, the layer-dependent electronic and optical properties have been studied by varying layer thickness and stacking order. Based on the quantum theory of atoms in molecules, topological analyses on interatomic interactions of layered MX2 and WX2/MoX2, including bond degree (BD), bond length (BL), and bond angle (BA), have been detailed to probe structure-property relationships. Results show that M-X and X-X bonds are strengthened and weakened in layered MX2 compared to the counterparts in bulks. X-X and M-Se/Te are weakened at compressive strain while strengthened at tensile strain and are more responsive to the former than the latter. Discordant BD variation of individual parts of WX2/MoX2 accounts for exclusively distributed electrons and holes, yielding type-II band offsets. X-X BL correlates positively to binding energy (Eb), while X-X BA correlates negatively to lattice mismatch (lm). The resulting interlayer distance limitation evidences constraint-free lattice of vdW structure. Finally, the connection between microscopic interatomic interaction and macroscopic electromagnetic behavior has been quantified firstly by a cubic equation relating to weighted BD summation and static dielectric constant.