Short answer: If that formula refers specifically to electromagnetic radiation, then $a = 1$ exactly.
If you forcibly set up a distribution of photons with $a \neq 1$ in your formula, that system is not in equilibrium, and will evolve to a different temperature (and the same total energy) such that $a=1$. The new state, with $a=1$ and $T^{\prime} \neq T$ will be the maximum entropy distribution for a bath of photons with given energy.
More generally, if we're considering the energy density of all kinds of generalized "radiation" then $a$ counts the number of (approximately) massless degrees of freedom. For the kind of temperatures we typically talk about, photons are the only particles with $m \ll T$ so $a=1$. In the early universe, several particles satisfied this constraint, and $a \gg 1$. In more detail:
The Planck blackbody distribution is equivalent to the Stefan-Boltzmann law for radiation.
The Stefan-Boltzmann law can be derived by looking at the spectrum of waves in thermal quantum field theory (which is the appropriate model when describing relativistic particles; since $m \ll T$ the particles we're modeling are moving at relativistic speeds).
In the thermal QFT framework, $a$ counts the number of (approximately massless) waves/fields/particles in the theory. Certain fields can also have fractional contributions to $a$ if they are not exactly massless, but only approximately so. For a summary of how $a$ evolves through the history of the universe (based on our current understanding) see section 21.3.2 here.
If only a small part of the cavity has this temperature (and the rest is cooled to near 0 K, or imagine dark sky in space with sun), the radiation still has the correct spectrum, but is not isotropic [...]
Further, that is not an equilibrium situation, so the discussion above doesn't apply.