If everything was completely smooth at the atomic scale, you’d just slide off some materials and stick to others (things with intermolecular forces, eg van der waals).
However, in the macro world, surfaces look more like stepped terrain, with hills and valleys. These can lock together between materials, forming friction. Think atomic scale velcro.
Latest Answers