The formation of bulges, discs and two-component galaxies in the CANDELS Survey at z < 3