It does and doesn't have anything to do with gravity.
Far out in intergalactic space are vast regions with almost no matter, not merely millimeters between atoms, or even meters, but kilometers or more. In the middle of these, anything larger than a diffuse cloud of cold gas may be many parsecs away. Even out there, though, a hypothetical astronaut leaving their hypothetical spacecraft for an EVA would simply hang around very near the craft unless they accelerated relative to it. There is nothing that would make the craft "fall away and leave them behind". Simple inertia is enough to keep them close together.
But in Earth orbit, of course, there are quite a few quite large masses quite nearby. However, in each case, the distance between the center of gravity of the large body (Earth, the Sun, the Moon, etc etc etc) and the CG of the spacecraft is almost exactly the same as the distance between that same CG and the CG of the astronaut. And likewise, the mass of the spacecraft or astronaut is effectively irrelevant when considering the acceleration. So in Earth orbit, the ISS does "fall away", but so does the astronaut, at almost exactly the same speed. That is in fact what an orbit is: continuously falling away from the straight-line course that would otherwise be taken, at such a high speed that the ballistic curve of the fall matches the curve of the planet. So here, inertia plus gravity keeps them together.
The gravitational environment in orbit is sometimes referred to as microgravity. This is more accurate than the other term, zero-g, but both are an approximation of the relative accelerations; because everything around you is in constant freefall at the same acceleration and velocity, there's no large force to make you move relative to your immediate surroundings if you let go of the wall or ceiling or floor. But because there are very small differences in distance and therefore gravity, "microgravity" is more accurate: an astronaut in the closest-to-Earth (or farthest-from-Earth) sections of the ISS could very slowly start drifting relative to the whole structure. But this is so slow that rather than taking a fraction of a second to fall a meter or a yard, it could very easily take many hours.