How do hardwood flooring expansion gaps work?
It's more accurate to say that the wood fibers swell rather than the wood moves. A board which is nailed down will still swell and contract around the nails, generally leading to a larger hole and squeaky floor. The nails hold the floor down and prevent gross movements, such as the floorboards sliding around underfoot.

Another key point to grasp is that boards swell along the growth rings in an amount proportional to their size. For practical purposes that means they really only have noticeable changes in width and it's a couple of percent of the width of the board. Adding an extra 1/64" to any individual board isn't a big deal, but it can add up across a lot of boards.

The gap is really about averting disaster. You're a board soaking up humidity. The tongue and groove joint gets a bit tighter, taking up some of the slack. Nail holes enlarge or nails bend slightly as you shove your neighbor aside an imperceptible amount. The floor remains flat and all is well, unless you're tight against the wall to begin with. In that case boards swell, and they press on their neighbors. They can't move sideways or down, so they go up. Boards cup, edges rise, the floor is warped.