With a Curie temperature just above room temperature, AlFe2B2 is a useful magnetocaloric material composed of earth-abundant elements. We employ temperature-dependent high-resolution synchrotron X-ray diffraction to establish with high certainty that the paramagnetic to ferromagnetic transition in AlFe2B2 is of second order, showing no discontinuity in lattice parameters or cell volume. Nevertheless, the lattice parameters undergo anisotropic changes across the transition with distinct differences in the thermal expansion coefficients. While the a and b lattice parameters show a positive thermal expansion, c shows a negative thermal expansion. We link these changes to the respective interatomic distances to determine the contribution of magnetism to the anisotropic structural evolution. The work underpins the possible role of magnetostructural coupling in driving the magnetocaloric effect in AlFe2B2.