The problem is that light travels different distances in the two cases!
The light does not travel different distances in the two cases. In fact, your drawing even shows that it travels the same distance in both cases.
In the accelerated frame light will travel horizontally and a straight path, even if the observer inside think that it is curved, the real distance traveled is the straight horizontal path.
Your mistake is here. In the accelerated frame (AF) the light does not travel on a straight path. The straight path is in the inertial frame (IF). In fact, the straight path in the IF can be used to derive the curved path in the AF, and it is the curved path in the AF that (through the equivalence principle) tells us that light curves in a frame at rest in a gravitational field (GF). The math is as follows:
In special relativity the reference frame of a uniformly accelerating object is the Rindler coordinates. This is the AF of the equivalence principle. The metric in the AF is $$ds^2 = -\frac{a^2 x^2}{c^2} dt^2 + dx^2 + dy^2 + dz^2$$ This formula determines all times and distances in the AF.
In general relativity, the standard metric for a spherical gravitating body is the Schwarzschild metric. Where the metric in the standard coordinates is given by: $$ds^2 = -\left(1-\frac{R}{r}\right) c^2 dt^2 + \left(1-\frac{R}{r}\right)^{-1} dr^2 + r^2 d\theta^2 + r^2 \sin^2(\theta) d\phi^2$$ where $R$ is the Schwarzschild radius.
The equivalence principle says that in a small region of spacetime around any single event in a curved spacetime, we can expand the metric to first order and get a GF that matches the AF locally. We will expand the Schwarzschild metric around the reference event $(t,r,\theta,\phi) = (0,r_0,\pi/2,0)$. When we expand the factor $\left(1-\frac{R}{r}\right)$ we get $$\left(1-\frac{R}{r}\right) \approx 1 - \frac{R}{r_0}+\frac{R}{r_0} \delta r$$$$ ds^2 \approx - \left( 1 - \frac{R}{r_0}+\frac{R}{r_0} \delta r \right) c^2 dt^2 + \left(1 - \frac{R}{r_0}+\frac{R}{r_0} \delta r\right)^{-1} dr^2 + \delta r^2 d\theta^2 + \delta r^2 d\phi^2 $$ where the $\delta$ indicates the Schwarzschild coordinates near the reference event (e.g. $r=r_0+\delta r$ and $dr = d\delta r$) and the approximations are to first order per the equivalence principle.
Now, from there we make the coordinate transformation $$\frac{R^2 \rho^2}{4 r_0^4}=1-\frac{R}{r_0} + \frac{R}{r_0^2}\delta r$$$$\frac{a\tau}{c^2}=\frac{R}{2 r_0^2}t$$$$\delta r^2 d\theta^2 = dy^2$$$$\delta r^2 d\phi^2 = dz^2$$ Transforming the local GF metric with this transformation gives $$ds^2 = -\frac{a^2 \rho^2}{c^2} d\tau^2 + d\rho^2 + dy^2 + dz^2$$ which exactly matches the AF metric from above: $$ds^2 = -\frac{a^2 x^2}{c^2} dt^2 + dx^2 + dy^2 + dz^2$$ with $\rho \to x$ and $\tau \to t$.
Because the metrics of the AF and the GF match exactly that means that all angles match, all speeds match, all times match, and all distances match.