Transient dynamics leading to self-oscillations in nanomagnets driven by spin-polarized currents