Ballistic spin resonance was experimentally observed in a quasi-one-dimensional wire by Frolov et al. [Nature (London) 458, 868 (2009)]. The spin resonance was generated by a combination of an external static magnetic field and the oscillating effective spin-orbit magnetic field due to periodic bouncings of the electrons off the boundaries of a narrow channel. An increase of the D'yakonov-Perel spin relaxation rate was observed when the frequency of the spin-orbit field matched that of the Larmor precession frequency around the external magnetic field. Here we develop a model to account for the D'yakonov-Perel mechanism in multisubband quantum wires with both the Rashba and Dresselhaus spin-orbit interactions. Considering elastic spin-conserving impurity scatterings in the time-evolution operator (Heisenberg representation), we extract the spin relaxation time by evaluating the time-dependent expectation value of the spin operators. The magnetic field dependence of the nonlocal voltage, which is related to the spin relaxation time behavior, shows a wide plateau, in agreement with the experimental observation. This plateau arises due to injection in higher subbands and small-angle scattering. In this quantum mechanical approach, the spin resonance occurs near the spin-orbit-induced energy anticrossings of the quantum wire subbands with opposite spins. We also predict anomalous dips in the spin relaxation time as a function of the magnetic field in systems with strong spin-orbit couplings.