Observations of dark matter dominated dwarf and low surface brightness disk galaxies favor density profiles with a flat-density core, while cold dark matter (CDM) N-body simulations form halos with central cusps, instead. This apparent discrepancy has motivated a re-examination of the microscopic nature of the dark matter in order to explain the observed halo profiles, including the suggestion that CDM has a non-gravitational self-interaction. We study the formation and evolution of self-interacting dark matter (SIDM) halos. We find analytical, fully cosmological similarity solutions for their dynamics, which take proper account of the collisional interaction of SIDM particles, based on a fluid approximation derived from the Boltzmann equation. The SIDM particles scatter each other elastically, which results in an effective thermal conductivity that heats the halo core and flattens its density profile. These similarity solutions are relevant to galactic and cluster halo formation in the CDM model. We assume that the local density maximum which serves as the progenitor of the halo has an initial mass profile

, as in the familiar secondary infall model. If

= 1/6, SIDM halos will evolve self-similarly, with a cold, supersonic infall which is terminated by a strong accretion shock. Different solutions arise for different values of the dimensionless collisionality parameter,

, where

is the SIDM particle scattering cross section per unit mass,

is the cosmic mean density, and

is the shock radius. For all these solutions, a flat-density, isothermal core is present which grows in size as a fixed fraction of

. We find two different regimes for these solutions: 1) for $Q < Q_{th}({\simeq} 7.35{\times} 10^{-4}$), the core density decreases and core size increases as Q increases; 2) for $Q > Q_{th}$, the core density increases and core size decreases as Q increases. Our similarity solutions are in good agreement with previous results of N-body simulation of SIDM halos, which correspond to the low-Q regime, for which SIDM halo profiles match the observed galactic rotation curves if

, or

. These similarity solutions also show that, as

, the central density acquires a singular profile, in agreement with some earlier simulation results which approximated the effects of SIDM collisionality by considering an ordinary fluid without conductivity, i.e. the limit of mean free path

. The intermediate regime where

or

, for which we find flat-density cores comparable to those of the low-Q solutions preferred to make SIDM halos match halo observations, has not previously been identified. Further study of this regime is warranted.