Using spectral methods, we analyse the orbital structure of prolate/triaxial dark matter (DM) haloes in N-body simulations in an effort to understand the physical processes that drive the evolution of shapes of DM haloes and elliptical galaxies in which central masses are grown. A longstanding issue is whether the change in the shapes of DM haloes is the result of chaotic scattering of the major family of box orbits that serves as the backbone of a triaxial system, or whether they change shape adiabatically in response to the evolving galactic potential. We use the characteristic orbital frequencies to classify orbits into major orbital families, to quantify orbital shapes and to identify resonant orbits and chaotic orbits. The use of a frequency-based method for distinguishing between regular and chaotic N-body orbits overcomes the limitations of Lyapunov exponents which are sensitive to numerical discreteness effects. We show that regardless of the distribution of the baryonic component, the shape of a DM halo changes primarily due to changes in the shapes of individual orbits within a given family. Orbits with small pericentric radii are more likely to change both their orbital type and shape than orbits with large pericentric radii. Whether the evolution is regular (and reversible) or chaotic (and irreversible), it depends primarily on the radial distribution of the baryonic component. The growth of an extended baryonic component of any shape results in a regular and reversible change in orbital populations and shapes, features that are not expected for chaotic evolution. In contrast, the growth of a massive and compact central component results in chaotic scattering of a significant fraction of both box and long-axis tube orbits, even those with pericentre distances much larger than the size of the central component. Frequency maps show that the growth of a disc causes a significant fraction of halo particles to become trapped by major global orbital resonances. We find that despite the fact that shape of a DM halo is always quite oblate following the growth of a central baryonic component, a significant fraction of its orbit population has the characteristics of its triaxial or prolate progenito