We study the glass formation in two- and three-dimensional Ising and Heisenberg spin systems subject to competing interactions and uniaxial anisotropy with a mean-field approach. In three dimensions, for sufficiently strong anisotropy the systems always modulates in a striped phase. Below a critical strength of the anisotropy, a glassy phase exists in a finite range of temperature, and it becomes more stable as the system becomes more isotropic. In two dimension the criticality is always avoided and the glassy phase always exists.