Linear carbon chains are common in various types of astronomical molecular sources. Possible formation mechanisms involve both bottom-up and top-down routes. We have carried out a combined observational and modeling study of the formation of carbon chains in the C-star envelope IRC +10216, where the polymerization of acetylene and hydrogen cyanide induced by ultraviolet photons can drive the formation of linear carbon chains of increasing length. We have used ALMA to map the emission of 3 mm rotational lines of the hydrocarbon radicals C_2_H, C_4_H, and C_6_H, and the CN-containing species CN, C_3_N, HC_3_N, and HC_5_N with an angular resolution of 1". The spatial distribution of all these species is a hollow 5-10" wide spherical shell located at a radius of 10-20" from the star, with no appreciable emission close to the star. Our observations resolve the broad shell of carbon chains into thinner subshells that are 1-2" wide and not fully concentric, indicating that the mass-loss process has been discontinuous and not fully isotropic. The radial distributions of the species mapped reveal subtle differences: while the hydrocarbon radicals have very similar radial distributions, the CN-containing species show more diverse distributions, with HC_3_N appearing earlier in the expansion and the radical CN extending later than the rest of the species. The observed morphology can be rationalized by a chemical model in which the growth of polyynes is mainly produced by rapid gas-phase chemical reactions of C_2_H and C_4_H radicals with unsaturated hydrocarbons, while cyanopolyynes are mainly formed from polyynes in gas-phase reactions with CN and C_3_N radicals.