Further to planar single-layer hexagonal structures, GaN and AlN can also form free-standing, single-layer structures constructed from squares and octagons. We performed an extensive analysis of dynamical and thermal stability of these structures in terms of ab initio finite-temperature molecular dynamics and phonon calculations together with the analysis of Raman and infrared active modes. These single-layer square-octagon structures of GaN and AlN display directional mechanical properties and have wide, indirect fundamental band gaps, which are smaller than their hexagonal counterparts. These density functional theory band gaps, however, increase and become wider upon correction. Under uniaxial and biaxial tensile strain, the fundamental band gaps decrease and can be closed. The electronic and magnetic properties of these single-layer structures can be modified by adsorption of various adatoms, or by creating neutral cation-anion vacancies. The single-layer structures attain magnetic moment by selected adatoms and neutral vacancies. In particular, localized gap states are strongly dependent on the type of vacancy. The energetics, binding, and resulting electronic structure of bilayer, trilayer, and three-dimensional (3D) layered structures constructed by stacking the single layers are affected by vertical chemical bonds between adjacent layers. In addition to van der Waals interaction, these weak vertical bonds induce buckling in planar geometry and enhance their binding, leading to the formation of stable 3D layered structures. In this respect, these multilayers are intermediate between van der Waals solids and wurtzite crystals, offering a wide range of tunability.