Atomic scale energetics, structure, and formation mechanisms of solid and liquid junctions occurring between a solid metal tip and a clean metal surface or between the tip and a liquid film of hexadecane molecules adsorbed on a solid surface, are investigated using large-scale molecular dynamics simulations. Additionally, structural and dynamical properties of adsorbed hexadecane films of variable thickness are discussed. Upon approach of the tip toward the surface a jump-to-contact phenomenon leads to the formation of an adhesive contact between the two. The solid intermetallic junctions exhibit crystalline structure and their elongation mechanism, upon slow retraction of the tip from the surface after contact, involves a sequence of plastic deformations and yield processes, coupled with structural rearrangements. The molecular liquid is layered in the capillary junction for small separations between the two confining solid surfaces. Further separation results in a transition to a liquid-like region in the middle of the elongated liquid column. Investigations of the molecular scale origins of capillary liquid junction formation, as well as consequences of solid and liquid junctions for force measurements via atomic force microscopy, are discussed. A brief discussion of the mechanism of collapse and spreading of a gold nano-droplet deposited on a nickel surface is included.