Cavity radiation says the number of modes in the cavity increases with frequency, or shorter wavelength, because more modes can fit in. But consider a square box with sides L with a small hole. EM radiation of wavelength 2L can fit a half wavelength in the cavity horizontally exactly with nodes at the walls. In all resources on black-body radiation I have seen, this lowest frequency is called "one" mode. But I can fit an almost infinite number of halfwavelengths inside the box just horizontally, let alone vertically and diagonally. What am I missing? Why can wavelength 2L only fit once?
In a three-dimensional resonator the wave modes are usually characterized by three numbers: in a rectangular box these simply correspond to the numbers of wave lengths fitting along different directions parallel to the box edges. That is, we have something like $$ 2L_x=N_x\lambda, 2L_z=N_y\lambda, 2L_z=N_z\lambda. $$ This ultimately comes from solving the Maxwell equations by separation of variable technique.
Here are the first notes on rectangular cavities that popped-up in Google: Cavities with Rectangular Boundaries (there are likely a lot more.)