Single-layer and bilayer carbon and hexagonal boron nitride nanoscrolls as well as nanoscrolls made of bilayer graphene/hexagonal boron nitride heterostructure are considered. Structures of stable states of the corresponding nanoscrolls prepared by rolling single-layer and bilayer rectangular nanoribbons are obtained based on the analytical model and numerical calculations. The lengths of nanoribbons for which stable and energetically favorable nanoscrolls are possible are determined. Barriers to rolling of single-layer and bilayer nanoribbons into nanoscrolls and barriers to nanoscroll unrolling are calculated. Based on the calculated barriers nanoscroll lifetimes in the stable state are estimated. Elastic constants for bending of graphene and hexagonal boron nitride layers used in the model are found by density functional theory calculations.