Counting modes Rayleigh-Jeans In the derivation of the Rayleigh-Jeans Law, we count the number of EM modes in a square cavity.
After calculating the number of allowed modes due to boundary conditions, we multiply it by a factor of 2 due to polarization of the EM waves.
What I do not understand is how, quantitatively, the polarization influences the number of modes allowed. 
We know each EM wave has a polarization which is a superposition of 2 perpendicular components, and supposedly this is where the factor comes from.
However, it makes sense to me that there would be infinite modes of vibration due to infinite polarizations, instead of only 2. 
How come you only have double the modes of vibration, when you have infinite polarizations?
 A: 
A travelling wave in the direction of the picture(or whatever direction) can have two polarizations, each perpendicular to its direction of propagation. Now, in the black body radiation derivation, we usually use a box as a black body and inside the box standing waves are formed. But standing waves are nothing more(mathematically as well as physically) than a superposition of two travelling waves. So, if each travelling wave that each standing wave consists of has these two polarizations, then logically the same is true for the standing wave. So, for a given "direction" of a standing wave(the direction is in quotations because it is not really travelling, I just said that so as to be able to explain to you the mechanisms more easily), we have two modes of oscillation of the electric field.
I hope I was of some help, even after many months since you asked the question!  
NOTE: If you want a mathematically more rigorous approach, I am afraid that I cannot help. I can offer to you a small mathematical intuition though. During the derivation of the formula, when we are using $k$-space to find the number of modes density(or just number of modes), each polarization has its own octant, so in order to be mathematically correct, you have to do the same derivation twice and sum the number of modes, so we just put the factor $2$ in front of the formula instead. And again, I can't offer a purely mathematical derivation(if there is any, because here we use our intuition, although something from vector calculus might help where you include the electric field as a vector field. Then, I am sure that mathematics can include the factor $2$ by themselves due to them actually considering that $\vec E$ is a vector, and thus we can describe it by $2$ other basis vectors(polarizations). And you can get rid of the third basis vector using Maxwell's equations, which one of them will make one basis vector depended on the other $2$).
