We'll take the case of a large cavity and a small hole.
If a photon leaves the small hole, its departure has essentially no effect on the rest of what's going on inside the cavity. It also is unaffected by the walls of the hole. This means that the escaping photon comes flying out the hole towards us just as if it had originated a light-year away from us and was simply zooming through space. In this sense, the hole in the cavity behaves as a photon source with no dynamics of its own: a perfect emitter.
Conversely, if a photon from outside the cavity is aimed just so that it zips right through the hole and into the cavity, its entrance has essentially no effect on what's going on outside the cavity and it quickly gets lost inside- and it doesn't come back out. Furthermore, the details of the hole itself have no influence on the transit of the photon through it, so the photon is not "colored" in any way by its passage, and leaves no trace behind once it goes through the hole. It is as if that photon were zooming away from us and into deep space, never to return. This means that the hole behaves as a perfect absorber of photons.