Recent attempts to make SiC diodes have revealed a problem with stacking fault expansion in the material, leading to unstable devices. In this paper, we present detailed results from a density-functional supercell calculation on the electronic structure of stacking faults which result from glide of Shockley partials in $3C\ensuremath{-}, 4H\ensuremath{-}$ and $6H\ensuremath{-}\mathrm{SiC}.$ It was found [Phys. Rev. B 65, 033203 (2002)] that both types of stacking faults in $4H\ensuremath{-}\mathrm{SiC}$ and two types of stacking faults in $6H\ensuremath{-}\mathrm{SiC}$ give rise to band states, which are strongly localized (confined within around 10 \AA{}) in the direction orthogonal to the stacking fault plane. Based on estimates of the band offsets between different polytypes and a simple quantum-well theory, we show that it is possible to interpret this one-dimensional localization as a quantum-well confinement effect. We also find that the third type of stacking fault in $6H\ensuremath{-}\mathrm{SiC}$ and the only stacking fault in $3C\ensuremath{-}\mathrm{SiC}$ do not give rise to states clearly separated from the band edges, but instead give rise to rather strongly localized band states with energies very close to the band edges. We argue that these localized near band edge states are created by stacking fault induced changes in the dipole moment associated with the hexagonal symmetry. In addition, we have also calculated the stacking fault energies, using both the supercell method and the simpler ANNNI (axial next nearest-neighbor Ising) model. Both theories agree well with the low stacking fault energies found experimentally.