There is a concept for Mars or other planet colonization that entails a pre-landing of robotic swarms... each unit has singular operations it can perform. More complex functions are done by combining 2 or more of the units together to do those more advanced functions. Replacement and new units can be produced with a 3-D style factory that uses prestaged materials or new materials extracted from the target planet. The goal of the hoard is slow but steady development of habitat, tunnels, or other environment that is ready when humans land at a later date.
Nothing says these can't be smaller units. Being smaller, you can get thousands of them on a single landing ship. Being smaller, their ability to combine into a larger functioning units would be important for larger/heavier tasks.
The design of connectors for these drones can vary based on the level of work the combined unit may be attempting to achieve. Magnets would align units in a simple fashion. Likewise, inverted magnets could keep parts separated for specific types of work... having a joint system capable of doing both across the collective would create different options for those units.
Mechanical joiners can be designed in just about any configuration you can imagine. These would be engineered to provide maximum strength for the heaviest or most stressful function those units would be expected to perform. Joints to create a wagon or platform for hauling would need less strength than units combining to make a crane arm for lifting and moving objects.
A combination of magnetics and mechanical configurations would offer the most versatile set of drones. Really it would depend on what your drone swarm needed to do as to how it was engineered.