Negative thermal expansion of two-dimensional magnets