Charge-density-wave order with momentum (2Q,0) and (0,2Q) within the spin-fermion model: Continuous and discrete symmetry breaking, preemptive composite order, and relation to pseudogap in hole-doped cuprates