  N-body simulations predict that CDM halo-assembly occurs in two phases: 1) a
fast accretion phase with a rapidly deepening potential well; and 2) a slow
accretion phase characterised by a gentle addition of mass to the outer halo
with little change in the inner potential well. We demonstrate, using
one-dimensional simulations, that this two-phase accretion leads to CDM halos
of the NFW form and provides physical insight into the properties of the mass
accretion history that influence the final profile. Assuming that the
velocities of CDM particles are effectively isotropised by fluctuations in the
gravitational potential during the fast accretion phase, we show that
gravitational collapse in this phase leads to an inner profile rho(r) ~ r^{-1}.
Slow accretion onto an established potential well leads to an outer profile
with rho(r) ~ r^{-3}. The concentration of a halo is determined by the fraction
of mass that is accreted during the fast accretion phase. Using an ensemble of
realistic mass accretion histories, we show that the model predictions of the
dependence of halo concentration on halo formation time, and hence the
dependence of halo concentration on halo mass, and the distribution of halo
concentrations all match those found in cosmological N-body simulations. Using
a simple analytic model that captures much of the important physics we show
that the inner r^{-1} profile of CDM halos is a natural result of hierarchical
mass assembly with a initial phase of rapid accretion.
