Symmetry nonrestoration and inverse symmetry breaking on the lattice