In Stefan's law, the radiated energy of a black body with a temperature of $T$ is $q = \sigma T^4$ Where $\sigma$ is Stefan's constant.
However, if it is surrounded by a medium then the net radiated energy is $q = \sigma(T^4 -t^4)$ Where $t$ is the temperature of the surroundings.
So my question is, Why the energy received from the surrounding is $\sigma t^4$?
Even that air doesn't have a definite area, volume..etc. why do we assume it follows Stefan's law?