Adding --with-hwloc=embedded fixed the problem. Yes, I have preinstalled hwloc (it is common since I also found hwloc on another Linux cluster that had the same kind of hw errors). I guess it was because mpich is not compatible with the system's preinstalled hwloc.
Perhaps a better approach is for mpich to check the hwloc at configure time (e.g., many petsc third party libraries are checked in this way), then report any compatibility issue and give clear messages to users asking them to either upgrade their hwloc or use the embedded one.