Stellar populations, stellar masses and the formation of galaxy bulges and discs at z < 3 in CANDELS