We present an analytical description of the merging of virialized haloes which is applicable to any hierarchical model in which structure grows via gravitational instability. The formulae are an extension of the Press-Schechter model. The dependence of the merger rate on halo mass, epoch, the spectrum of initial density fluctuations and the density parameter Ω0 is explicitly quantified. We calculate the distribution of halo formation times and survival times. We also describe a Monte Carlo method for constructing representative histories of merger events leading to formation of haloes of a prescribed mass. Applying these results to the age distribution of rich clusters of galaxies, we infer that a high value of the density parameter (Ω0 ≳ 0.5) is required to reproduce the substantial fraction of rich clusters that exhibit significant substructure, if such substructure only persists for a time 0.2t0 after a merger, where t0 is the present age of the universe. We also investigate the rate of infall of satellite galaxies into galactic discs, by combining our Monte Carlo technique for halo mergers with an estimate of the time required for dynamical friction to erode the orbits of the baryonic cores of the accreted galaxies. We find that, even for Ω0 = 1, the infall rate is low (provided that the satellite orbits are not too eccentric), and that we would expect only a modest fraction of stellar discs to be thickened or disrupted by this process.