WPILib explains this a whole lot better than me here
NOTE: Mechanism2d does not describe actual physical simulation of mechanisms. The Mechanism2d & Mechanism3d systems are exclusively used for display, and not for actual simulation.
Mechanism simulation is composed of three different components. Mechanisms, Roots, and Ligaments.
Mechanisms are the spaces onto which the simulation is drawn. On creation, they take their dimensions. They may then have components added to them through roots and ligaments. Lastly, they are sendable, meaning they can be logged (or otherwise sent to NetworkTables) and displayed in the application of your choice.
Roots are invisible starting points for mechanism ligaments. Roots are generated by calling the Mechanism.getRoot(name, x, y) method on a mechanism. This returns a root on that mechanism's display.
Ligaments are physical components of a mechanism, similar to bones in 3d modeling. Ligaments have an angle, length, width, and color, which can all be changed as needed using the setter Methods.
To create ligaments, use the .append() method on a root or other ligament. If you plan to append onto or otherwise access the ligaments after creation, save them into a variable.
To display the robot's mechanisms, you must update their positions in the periodic method. Do this each loop using the setter methods of the ligaments. Finally, after updating all of your mechanism's physical values, you must re-log (or otherwise output) the mechanism2d object.