How does radiation become black-body radiation? Textbooks treat black body radiation as radiation in thermal equilibrium with its environment (more specifically - with a black body): Planck's formula is essentially derived from the partition function.
\begin{align}
\hat{\rho}&=Z^{-1}e^{-\beta H_{ph}},&
 Z&=tr[e^{-\beta H_{ph}}]&
H_{ph}&=\sum_{\mathbf{k},\lambda}\hbar\omega_{\mathbf{k},\lambda} a_{\mathbf{k},\lambda}^\dagger a_{\mathbf{k},\lambda}
\end{align}
This is usually described as a cavity with a small opening, so that enough radiation escapes through the opening to be observable, but too little to significantly distort the thermal equilibrium.
In practice, this is rarely the case - most radiation described as black body radiation is in a strongly non-equilibrium state, being a flux flowing from a hot object (such as a lamp filament or a star) to much colder surroundings (as discussed in the comments to this question and the answers). Yet, such sources are rather well described by Planck's formula.
I see several possible explanations to this:

*

*the light source itself serves as a cavity, with the light making many trips back and forth before escaping (this does not sound very plausible to me)

*the light source is sufficiently thick that photons travelling through it are absorbed and reemitted multiple times before exiting the source, thus being in thermal quasi-equilibrium

*the radiation processes in the source are such that they approximate the Planck's curve: e.g., the thermal electrons in a lamp filament are themselves distributed according to Boltzmann's law; whereas in the case of a star, we have a complex composition of chemical elements, whose spectral lines form a nearly continuous spectrum, and whose excited states are occupied according to the Boltzmann law. While this sounds plausible, it significantly deviates from the reasoning that leads to Planck's formula.

Remarks:

*

*Another inconsistency in the Planck's formula, that is worth noting is that cavity radiation has discrete spectrum.

*A similar question, although less detailed, Relevant question on black-body aspects of solar radiation

*Another fine point that has surfaced in the answers here and those to a related question is whether black body radiation is radiation in thermal equilibrium OR whether it is the radiation emitted by the black body. In the former case, the bodies in which the radiation is in contact do not necessarily have to be black for the radiation to be described by the Planck's formula. In the latter case, the radiation does not have to be in equilibrium (although it would mean that neither is the black body, since it loses the energy via radiating). One could derive Planck's formula in both cases, which correspond to the second and third options proposed above (radiation comes to thermal equilibrium vs. the filament/star emits radiation that is already black.)

*Thread with discussion of how/whether/when discrete atomic spectrum in a gas gives rise to black body radiation: Difference in thermal radiation between condensed matter and gases
 A: Of your possibilities it is the second one that means that the blackbody approximation can be used in some cases.
Ideal blackbodies are really hard to produce in nature because of the interface you identify that causes a lack of thermodynamic equilibrium. The best you can do is hope that the region where there is a transition from your "blackbody" to the "outside" is as isothermal as possible.
In practice what matters is how far photons can travel compared to the length scale for the temperature to change at the interface. An object will become more and more like a blackbody if there is a sudden increase in photon mean free path, such that almost all of the photons that escape from the surface were emitted from material at the same temperature.
Prior to that, the mean free path of the photons is small, so that they are indeed absorbed and re-emitted on length scales which are small compared with the length scale on which temperatures vary. In these conditions, the radiation field is close to isotropic and the matter and radiation are close to thermodynamic equilibrium.
The discussion above applies to any candidate source of "blackbody" radiation, not just stars.
Once near to the "surface", if the mean free path lengthens, then there is clearly an anisotropy, because the photons can escape in one direction, but not in the other. There will be a loss of thermodynamic equilibrium and a significant temperature gradient over the regions from which the photons can escape. This is basically what is happening in the photosphere of a star and is why stellar spectra can be very different to the Planck function.
Note: Your option 3 probably isn't going on in most cases. The intrinsic spectrum of a thermal emitter is not the Planck function and in general would contain emission lines, recombination edges etc., even if the population of energy states and particle velocity distribution was characterised by a Maxwell-Boltzmann distribution at some temperature. What one can say is that a smaller amount of material is needed to become opaque to its own radiation if it has strong emission/absorption at all frequencies.
Edit: In response to the commentary on the bounty. There is no doubt at all that thermal emission - the radiation emitted by a small quantity of material in isolation, but characterised by a temperature - is not blackbody radiation. Take the example of material in the interior of a star at say $10^6$ K. We know that this material emits thermal bremsstrahlung and recombination radiation. This is not the Planck function. The intrinsic emission spectrum of such material can be observed by looking at the corona of the Sun and it consists of a continuum with a cut-off that is characteristic of the temperature accompanied by a host of emission lines.
A picture of a piece of the distinctly non-Planckian EUV spectrum attributable to thermal emission from the solar corona, measured by HINODE. (From  http://prc.nao.ac.jp/extra/uos/en/no07/ )

This radiation must be processed in order to become similar to the Planck function and this requires the radiation field to come into equilibrium with the environment. This cannot happen in the solar corona, because it isn't dense enough to be "optically thick". Conversely, in the solar interior the mean free path of photons is a mm, or much less at the wavelength of some recombination line. If you put a piece of material in such an environment at $10^6$ K then the radiation field will be the Planck function. The populations of the various energy states and the transitions between them reach an equilibrium with the radiation and the solution to that equilibrium  is the Planck function.
A: "most radiation described as black body radiation is in strongly non-equilibrium state, being a flux flowing from a hot object (such as a lamp filament or a star) to much colder surroundings"
It doesn't matter if the emitting object is at a higher temperature than the surroundings.  The wavelength of the peak of the black body curve indicates the temperature.
What's required for black body spectrum is that no other radiation is reflected from the body, hence the original name 'black body'.
For a star for example, radiation landing on it is absorbed, any reflection, especially compared to the radiation being emitted due to the temperature, would be negligible.
A: There is no "real" black bodies in the first place, this is a gross simplification for the sake of the formula derivation.
Real bodies are modelled in regard to their thermal radiation by combining the idealized black body with whatever we know about the real body spectrum, using the widespread symmetry in the electromagnetic world, as well as in thermodynamics.
The small opening in the cavity is just a model for the "blackness".
The size of the cavity being finite is not implied in the derivation. On the other hand, a macroscopic cavity of any size is a good approximation when one deals with sub-micrometer waves.
The derivation contains quite a few implicit simplifications, e.g. that the whole body (or at least, surface) has single constant temperature that is never really the case. The real bodies feature a finite internal thermal gradients. That's how we get complex spectra even out of sufficiently black boides (e.g. the Sun).
A: Your third bullet point suggestion is the one closest to the mark I think. Thermal equilibrium is itself a strong statement, which has implications for all the distribution functions etc. concerning all the degrees of freedom of the source. A source of electromagnetic radiation which is not itself bathed in thermal radiation is not in complete thermal equilibrium, but if it is close to equilibrium (e.g. because the emitted flux only changes the internal energy etc. in a quasistatic manner) then the radiation it emits is close to black body radiation, and it must be because the internal configuration of the body is close to the one it would have if there were a complete equilibrium. So all those microscopic processes---molecules, currents, electrons, etc---all settle to whatever it is they have to do to maximise entropy, and, for a body which absorbs in the relevant frequency range, this is the very same state which also emits radiation with the Planck distribution.
Once the radiation is on its way away from a localized source then, as you say, its distribution over direction is no longer the thermal (isotropic) form, but the distribution over frequency is decoupled from that because light does not interact with itself. So that property, at least, remains of black body form.
(Final remark: the discreteness of cavity radiation is to do with the size of the cavity. When we refer to 'black body radiation' we have in mind the thermodynamic limit where the cavity is large compared to the relevant wavelengths.)
A: Stars can be approximated by a black body, because the star's atmosphere is in local thermodynamic equilibrium. This is because the mean free path length of a photon is shorter than the length scale on which the temperature varies.
Using some simplifying assumptions, like an opacity that is independent of the wavelength, one can derive
$$
T^4 = \frac{3}{4}T_\mathrm{eff}^4 \left(\tau_{\perp} + \frac{2}{3} \right)
$$
which means that the effective temperature (roughly $5700\,$K for our sun) is actually found at a depth where the perpendicular opacity is $2/3$, so not at the surface (what ever that might be). This is because photons at that depth have a mean free path length longer than the height below the surface.
