The robot in this case can ask "roughly how far away is the wall in front of me, to the sides of me and behind me". Given that information it can rule out some places it might be, and figure out some more likely places. Then it moves a bit somewhere and says "OK, now how far away are the walls?".
You could imagine doing this in your house, blindfolded. You reach out and touch a wall in front of you - ok you know you are not in the middle of a room unless it's a small room. There's no wall to the sides of you reachable so you're not in a corner. You keep moving and measuring and you can work out where you probably are. If the walls either side of you and straight in front of you are far away, then you step forwards and the walls either side are suddenly touchable, you know you've just crossed from a room into a corridor. There's only one place in my house personally that can happen so I'd be able to say exactly where I was if that happened.
This is localisation. There's a harder problem called SLAM (simultaneous localisation and mapping) where you don't know what the world looks like or where you are and are trying to build up a model of the world and where you are in it.