Formation and Physical Properties of h-BN Atomic Layers: A First-Principles Density-Functional Study