When the macaron batter sits on the sheet tray prior to being baked, the outside dries a bit and becomes solid and inflexible (at least relative to the rest of the batter).
During the baking process, the batter inside is heated, which causes some of the water to turn
to steam and expand. This forces the interior batter to expand. It lifts the dried outer shell up, because that is the only direction it can go to start.
Once the harder shell is raised, some of the softer interior batter then can spread sideways as it expands. However, it is now directly exposed to the heat of the oven, and quickly sets itself before it has gone very far. That small bit that expanded sideways out from under the lifted shell is the foot.
This may be hard to visualize, so imagine a big restaurant style griddle, and a small disposable aluminum pie pan, upside down, over some unpopped popcorn.
As the popcorn pops, it cannot go sideways because the walls of the pie pan are in the way. So it ends up lifting the pan. Now it can spread sideways a bit, so there will be a rim or foot of popcorn around the pie pan, which will be an inch or two (or several cm for our metric friends) above the surface of the griddle.