We have investigated microstructural properties of GaAs:N and GaN:As layers using transmission electron microscopy. The samples were grown onto (001)-oriented GaAs substrates by RF-plasma assisted molecular beam epitaxy. It has been found that during the GaAs/GaAs:N epitaxial growth the supplied active nitrogen atoms gave rise to nanometer-size GaN crystallites formed in the GaAs matrix. In addition, silicon incorporation showed abnormal behavior at the two interfaces of the thin GaAs:N layer embedded in GaAs. A model is proposed for the formation of GaN crystallites in GaAs during the growth. In the GaN:As growth, the layer exhibited columnar growth, resulting in domains with different crystallographic orientation. With an increase of the film thickness, the zincblende structure changed to the wurtzite phase of GaN. The distribution of arsenic through the layer thickness was found to be inhomogeneous and be much higher near the GaN/GaAs interface compared to the region near the surface.