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.)
"Fit a wave in the box" does not mean drawing a horizontal wave with nodes on the walls with its vertical position being meaningful. You can indeed put very many such drawings there, stacked on top of each other. This kind of drawing, with multiple stacked waves, is meaningless in physics of cavity radiation.
What "fitting wave in the box" means is that 1) we assume that along single direction, there is only one wave in the box 2) its nodes coincide with the walls.
There is only one wave in the box because value of the wave at $x$ which we sometimes draw represents amplitude of electric field at the whole plane $yz$, as function of $x$. Because there is only one electric field at one time, there is only one wave. Thus a drawing of multiple stacked waves on top of each other does not correspond to the physical system being described.