Do the photons collide with each other as molecules do?
No. Remember that the vacuum Maxwell's laws are linear. You can just take two light waves, add them up, and get another solution. I.e., they just "pass through" each other. Photons do not collide.
(...Well, except that, in quantum electrodyanmics, photons can actually interact via virtual electron exchange. See: https://en.wikipedia.org/wiki/Two-photon_physics . However, this effect is so incredibly tiny, and completely irrelevant to studying black body radiation.)
How to picture temperature and thermal equilibrium for photon gas?
Remember that, ultimately, light is created by jiggling charges. That is the main interaction going on. The material of the wall is made up of a bunch of protons and electrons that get jiggled when light hits them. This causes them to jiggle themselves and release more light. Different materials obviously have different propensities for being jiggled at certain wavelengths. (Glass and bricks let some wavelengths pass through and block others). But we don't really have to concern ourselves with the exact details of the material of the box, as long as we know that it doesn't let light get out.
So the main thing you should picture is you have a box, and there is thermal kinetic motion in the atoms comprising the box. These atoms are jiggling around and bumping into their neighboring atoms. However, they are also coupled to the electromagnetic field, meaning that when they jiggle, they'll also create light. This light will travel from one end of the box to the other, where it will be absorbed by an atom there, causing more jiggling, etc. This is the general picture for a "photon gas." If you were to look at the interior of the box, you'd see a bunch of photons just traveling past each other, getting absorbed/emitted by different atoms in the box.
Now, thinking about just classical Maxwell's laws (instead of photons) if you have one wave moving the to the left, like $\sin(\omega t + k x)$, and add it to a wave moving the right, like $\sin(\omega t - k x)$, you get something like $\sin(\omega t) \sin(k x)$, i.e. a standing wave. So these photons moving past each other create a standing wave, which has the boundary condition that it is $0$ on the boundary of the box.
Edit: The beautiful insight of equilibirum statistical mechanics is that you don't have to worry about all the exact particulars of how things interact with each other. The Boltzmann distribution $P \propto e^{- E/kT}$ is derived on such general grounds that it is true no matter what the particulars are. It just arises when the system is free to exchange energy with itself and has done so for a really long time.
A good example is a kiln or an oven. You can just heat it up by, say, lighting a fire. It will then start to glow. Infrared for low temperatures, then red, orange, yellow, and blue, etc. for higher and higher temperatures.
Photons can certainly escape the cavity. You could make a little door on the side of the kiln, open it up and see it glowing inside.
Edit: OP asks in the comments
Is it possible that the photon can come out of the cavity? I mean it's not necessary that the atom that emits the photon in the same direction it came from. So it might possible that it emits the photon in another way so that it gets absorbed into another atom and so on, it gets came out of the cavity from an outer atom. I think the chance is very less but is it possible.
Well this gets into a delicate issue. If a photon is released in the wrong direction, it will just get absorbed again and just jiggle the neighboring atom instead of traveling freely through the cavity. In a kiln, the walls will be pretty good insulators, meaning that while the interior of the kiln is hot, the outside is cold (at room temperature). If the outside of the kiln were to reach the same temperature as the inside of the kiln though, then yes it would glow red. But its typically surrounded by "cold" air that suppresses the jiggling of atoms on the outside.
If the walls of the kiln were a good conductor of heat, like a metal (a terrible idea!) then they would indeed start to glow red, as it would be hot throughout. The atoms on the exterior of the kiln would then jiggle and release light into the surrounding environment.
How jiggling atoms produce photons? I know photons can be produced with the transition of electrons from one orbit to another. Is it due to Bremsstrahlung?
Yes I suppose you could say it is more or less like bremsstrahlung. But in bremsstrahlung you are usually thinking about the movement of a single charged free particle. In matter it's more often due to the jiggling of an electron which is bound in an atom (not free). When a light wave passes over an atom it deforms the orbital which "wiggles" the charge distribution of the electron. It's not really about transitioning energy levels--- when that happens you get distinct emission lines, not thermal radiation across many wavelengths. In general it has more to do with the polarization vector of the atom oscillating in time.