That's called the mechanical theory of adhesives. Another theory of how glues work suggests the adhesive can diffuse into the surface and vice-versa, with molecules swapping over at the join and mingling together. This is called the diffusion theory.