The logic here is not correct. To go from a facet index to the geometry indices, use dolfinx.mesh.entities_to_geometry
.
See for instance Extract the coordinates of the boundary points and the value of a function on them - #4 by dokken
I would also suggest trying to visually debug it as done in: Selecting boundary facets to apply traction boundary condition - #2 by dokken