We combine high-resolution Hubble Space Telescope/WFC3 images with multi- wavelength photometry to track the evolution of structure and activity of massive (M-* > 10(10)M(circle dot)) galaxies at redshifts z = 1.4-3 in two fields of the Cosmic Assembly Near-infrared Deep Extragalactic Legacy Survey. We detect compact, star- forming galaxies (cSFGs) whose number densities, masses, sizes, and star formation rates (SFRs) qualify them as likely progenitors of compact, quiescent, massive galaxies (cQGs) at z = 1.5-3. At z greater than or similar to 2, cSFGs present SFR = 100-200M(circle dot) yr(-1), yet their specific star formation rates (sSFR similar to 10(-9) yr(-1)) are typically half that of other massive SFGs at the same epoch, and host X-ray luminous active galactic nuclei (AGNs) 30 times (similar to 30%) more frequently. These properties suggest that cSFGs are formed by gas- rich processes (mergers or disk- instabilities) that induce a compact starburst and feed an AGN, which, in turn, quench the star formation on dynamical timescales (few 10(8) yr). The cSFGs are continuously being formed at z = 2-3 and fade to cQGs down to z similar to 1.5. After this epoch, cSFGs are rare, thereby truncating the formation of new cQGs. Meanwhile, down to z = 1, existing cQGs continue to enlarge to match local QGs in size, while less-gas-rich mergers and other secular mechanisms shepherd (larger) SFGs as later arrivals to the red sequence. In summary, we propose two evolutionary tracks of QG formation: an early (z greater than or similar to 2), formation path of rapidly quenched cSFGs fading into cQGs that later enlarge within the quiescent phase, and a late-arrival (z less than or similar to 2) path in which larger SFGs form extended QGs without passing through a compact state.