Theory of coherent-oscillations generation in terahertz pump-probe spectroscopy: From phonons to electronic collective modes