Mass growth and density profiles of dark matter haloes in hierarchical clustering