Different behaviour of a mesh coming from generate_mesh() resp. UnitSquareMesh()?

Gmsh supports physical tags, which can be loaded into dolfin, see for instance:
the second section of:
Mesh generation and conversion with GMSH 4.6.0 and PYGMSH 6.1.1 | Jørgen S. Dokken on how to create physical markers,
and
Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #7 by dokken
for how to get the physical tags from msh file to dolfin,
or Electromagnetics example — FEniCS-X tutorial on how to create phyiscal markers using the GMSH python API.