Viewpoint 1: Because gravity or other forces that are holding the thing concerned (be it a galaxy, a ruler or an atom) together are way stronger than the "force" caused by the expansion of space. So strictly speaking, space does in fact expand everywhere, including the space inside an atom between its nucleus and its electrons. But gravity or other forces keep the size of the object constant. Viewpoint 2: The space within the thing concerned (such as the space inside an atom) is of a different nature from the space between two galaxies (the space that "occupies" the vast region of space). Let's call the former type-1 space and the latter type-2 space. Only type-2 space expands for some reason; eg., type-2 space is filled with (or littered with) dark energy, which drives the expansion, but type-1 space is void of dark energy. I think the correct or the widely accepted viewpoint is the first one. But I don't understand how exactly the size of an object is being kept constant.