An ensemble is essentially a collection of all possible energy states a system can be in. That is why in its most general form, the canonical ensemble is given as
\begin{equation}
Q= \sum_i e^{-\beta E_i}
\end{equation}
Which shows that the ensemble is a sum over all possible thermodynamical configuarations of the system. Statistical physics gives us the possibility of using probability to understand extremely large, complex systems so you can obtain the probability of the system being in some discrete energy state, $E_s$.
\begin{equation}
\mathcal{P_s} = \frac{e^{-\beta E_s}}{\displaystyle \sum_i e^{-\beta E_i}}
\end{equation}
Now you are right that when dealing with position and momentum space, that we have an infinite number of possible "energy states". This is why we utilize the classical picture of the ensemble. Think back to the general form where we sum over discrete energy states of the system. Since there are theoretically many states in position and momentum space, we can approximate the states to be so close together that they are continuous as opposed to discrete. This is why we can instead utilize an integration over all the "energy states" as opposed to a sum.
\begin{equation}
Q= \frac{1}{h^3} \int e^{-\beta H(q, p)} d\Gamma
\end{equation}
Where $d\Gamma$ is the integration over all position and momentum space, $d^3qd^3p$ and $H(q, p)$ is the Hamiltonian that describes the system. So for example, a single particle with translational kinetic energy and no potential with the Hamiltonian of $H = \displaystyle \frac{p^2}{2m}$, would give you the translational ensemble
\begin{equation}
Q = V \left( \frac{2 \pi m k_B T}{h^2} \right)^{3/2}
\end{equation}