The unexpected properties of a uniaxially expanded TiN bulk arising from increasing the layer spacing from equilibrium are explored using a first-principles approach. We reveal an unusual nonmagnetic-magnetic transition from a TiN bulk to its monolayer. We also investigate the electronic and magnetic structures of a few TiN atomic layers. We find that the bilayer and trilayer, like the TiN bulk, are nonmagnetic poor metals. On the other hand, the monolayer TiN is found to carry a magnetic moment on its Ti atoms, and likely be a semiconductor. The unpaired electron giving rise to magnetism on Ti is primarily in the orbital perpendicular to the layers, and we find it is freed to give rise to magnetism when the layers are slightly separated. We find two different antiferromagnetic states possible on the monolayer, as well as one ferromagnetic, with one of the antiferromagnetic being the lowest energy. The exchange couplings between Ti atoms in such a monolayer are calculated to be antiferromagnetic for both the nearest-neighbor and next-nearest-neighbor sites. We also analyze the binding nature of both the monolayer and bilayer TiN by examining the predominant binding orbitals.