Say a photon hits a free electron at rest. I understand that there is a formula for the Compton scattering when the photon is scattered with an angle $\theta$, but I don't understand what determines that angle $\theta$. If one photon hits such an electron, won't it be scattered through a unique angle? It seems it is not so, since there is the angle $\theta$ as a parameter.
As all scattering process in quantum mechanics, finding the scattered particle at a particular direction is random, because the scattered wavefunction is not a plane wave.
The usual derivation of Compton scattering overlooks the wave nature of electron and light, and hence gives you false perception that the scattered electrons and photons have a definite four-momentum in any individual event. In fact, they are in superposition of momentum eigenstates after scattering.
At low photon energies, the scattering process is sometimes called Thompson scattering. You can ignore relativistic effects, and simply say that the electric field of the photon causes the electron to oscillate in the plane of the electric field. That causes the electron to emit dipole radiation. The probability to scatter in a particular direction is then $\propto \sin^2\theta$, where $\theta$ is the same angle that you're using, and is the angle away from the plane of the electric field of the photon. Jackson derives the angular dependence in chapter 9, section 9.2. The final equation is (9.23).
At high photon energies, the angular dependence is given by the Klein-Nishina equation, which comes from a full QED treatment. I've never had to use QED, so I don't know the derivation. It looks like it also only depends on the photon's initial energy and the scattering energy.