In Lagrangian mechanics all forces arising by constraints are ignored provided they are "orthogonal to the virtual displacements" (see below).
In fact, the general form of E-L equations for the curve $t \mapsto (t, q(t), \dot{q}(t))$ representing the motion of the system are written this way
$$\frac{d}{dt}\left(\frac{\partial T(t,q(t),\dot{q}(t))}{\partial \dot{q}^k}\right)- \frac{\partial T(t,q(t),\dot{q}(t))}{\partial q^k}= Q_k(t,q(t), \dot{q}(t))\quad k=1,2,\ldots, n$$
together with
$$\frac{dq^k}{dt} = \dot{q}^k(t)\quad k=1,2,\ldots, n$$
where $$Q_k(t,q,\dot{q}) = \sum_{i=1}^N {\bf F}_i \cdot \frac{\partial {\bf x}_i}{\partial q^k}\tag{1}$$
and $${\bf F}_i = {\bf f}_i + {\bf \phi}_i\tag{2}$$ is the total force acting on the $i$-th point of matter with position ${\bf x}_i$ in our reference frame where we compute the kinetic energy $T$. I henceforth assume that the points are $N$ and the free coordinates are $n>0$, so that $3N-n=c\geq 0$ is the number of independent constraints.
In (2) I distinguish between forces ${\bf f}_i$ whose I know the functional form as a function of the positions and velocities of all matter points of the Lagrangian system and the reactive forces ${\bf \phi}_i$ which are unknowns of the problem and are physically due to the constraints.
As soon as these reactive forces satisfy the postulate of ideal reactive forces, we have
$$\sum_{i=1}^N {\bf \phi}_i \cdot \frac{\partial {\bf x}_i}{\partial q^k}=0\:,\qquad k=1,2,\ldots, n\tag{3}$$
and we can completely ignore them in (1) and thus also in E.-L. equations.
Powerfulness of E.-L. method is also based on this fact: reactive forces disappear and the reaming equations satisfy the general hypotheses permitting existence and uniqueness of solutions. Once known the motion of the system the unknown forces ${\bf \phi}_i$ are constructed out of Newtonian equation ${\bf \phi}_i = m_i {\bf a}_i - {\bf f}_i$.
The postulate of ideal reactive forces just requires that (3) is true.
There are many equivalent ways to state the same requirement. The "classical" old-fashioned statement says
$$\sum_{i=1}^N {\bf \phi}_i \cdot \delta {\bf x}_i =0 \tag{4}$$
for every "virtual displacement" $\delta {\bf x}_i$. However, since
$$\delta {\bf x}_i = \sum_{k=1}^n\frac{\partial {\bf x}_i}{\partial q^k} \delta q^k$$
for arbitrary numbers $\delta q^k \in \mathbb R$, (4) is completely equivalent to (3).
NB. The modern view on this matter is that the set of reactive forces $({\bf \phi}_1, \ldots {\bf \phi}_N)$ at everyfixed time must be normal to the $n$-dimensional submanifold in the $3N$ configuration space consisting of all possible configurations permitted to the system taking the $3N-n$ constraints into account. (3) just says it.
Let us come to your system. I will prove that (3) is automatically satisfied assuming that the $x$ axis is frictionless and the rope has no mass (so it completely transmits its tension).
Let us indicate by ${\bf X}$ the position of $M$ and by ${\bf x}$ that of $m$. The free coordinates are $q^1=x$ and $q^2=\theta$. We therefore have
$${\bf X}(x,\theta)= x{\bf e}_x$$
$${\bf x}(x, \theta) = (x+ r \sin \theta){\bf e}_x - r \cos \theta {\bf e}_y$$
Now let us consider the total reactive force ${\bf \phi}_M$ acting on $M$, it has two components. One is normal to the $x$ axis, since it is frictionless. The other is just provided by the tension $T$ of the ideal rope and thus
$${\bf \phi}_M \cdot \frac{\partial {\bf X}}{\partial x} = {\bf \phi}_M \cdot {\bf e}_x = T \sin \theta \:,$$
$${\bf \phi}_M \cdot \frac{\partial {\bf X}}{\partial \theta} = {\bf \phi}_M \cdot {\bf 0}=0\:.$$
Regarding $m$, the reactive force is only due to the tension ${\bf \phi}_m = T\cos \theta {\bf e}_y - T \sin \theta {\bf e}_x$ so that.
$${\bf \phi}_m \cdot \frac{\partial {\bf x}}{\partial x} = {\bf \phi}_m \cdot {\bf e}_x = -T \sin \theta$$
$${\bf \phi}_m \cdot \frac{\partial {\bf x}}{\partial \theta} = {\bf \phi}_m \cdot (r \cos \theta {\bf e}_x+ r \sin \theta {\bf e}_y) = T \cos \theta \sin \theta -T \sin \theta \cos \theta =0\:.$$
Summing together all contributions, we have
$${\bf \phi}_M \cdot \frac{\partial {\bf X}}{\partial x} + {\bf \phi}_m \cdot \frac{\partial {\bf x}}{\partial x} = T \sin \theta - T \sin \theta =0$$
$${\bf \phi}_M \cdot \frac{\partial {\bf X}}{\partial \theta} + {\bf \phi}_m \cdot \frac{\partial {\bf x}}{\partial \theta} = 0+ 0 =0\:.$$
You see that (3) is satisfied and thus you can completely omit reactive forces when writing E.-L. equations.
Finally, noticing that the remaining force is conservative we can re-write everything using the Lagrangian only as in your text.