Length Contraction And Simultaneity

I wanted to derive length contraction from the Lorentz transformation, but I keep getting stuck on problems with simultaneity in my derivation. At some point, I came across Wikipedia's article on Length Contraction where, in the section labeled "Derivation", it states

In an inertial reference frame $S^\prime$, $x_1^{\prime}$ and $x_2^{\prime}$ shall denote the endpoints for an object of length $L_0^\prime$ at rest in this system. The coordinates in $S^\prime$ are connected to those in $S$ by the Lorentz transformations as follows:

$x_1^{\prime} = \frac{x_1-vt_1}{\sqrt{1-\frac{v^2}{c^2}}}$ and $x_2^{\prime} = \frac{x_2-vt_2}{\sqrt{1-\frac{v^2}{c^2}}}$

As this object is moving in $S$, its length $L$ has to be measured according to the above convention by determining the simultaneous positions of its endpoints, so we have to put $t_1=t_2$. Because $L=x_2-x_1$ and $L_0^\prime=x_2^\prime-x_1^\prime$, we obtain

$L_0^{\prime} = \frac{L}{\sqrt{1-\frac{v^2}{c^2}}}.$

I understand everything except for the line which reads $L_0^\prime=x_2^\prime-x_1^\prime.$ After setting $t_1=t_2$, it is possible to write $L=x_2-x_1,$ since events $1$ and $2$ are simultaneous. However, in the primed inertial reference frame, which is moving with a nonzero velocity with respect to the laboratory frame, the events are not simultaneous. Therefore, how can it be that $L_0^\prime=x_2^\prime-x_1^\prime,$ since $t_1^\prime \neq t_2^\prime?$

You just confused the frames. In the derivation, $S'$ is the rest frame of the object of length $L'_0=x'_2-x'_1$. In that rest frame, the endpoints are simply at coordinates $x'_1$ and $x'_2$, regardless of $t'$. The length $L'_0$ in that rest frame is measured as the distance between two simultaneous events in that frame, i.e. events with $t'_1=t'_2$, and the result is, once again, $L'_0=x'_2-x'_1$. The world lines of both end points are vertical in that frame. Simple.
We want to know how this object looks like in another frame, $S$, which is moving relatively to $S'$. To measure the length $L_0$ in $S$, we have to see both endpoints simultaneously in $S$ i.e. impose $t_1=t_2$. That's exactly what they did and derived that in the frame $S$ where the object is moving, the length is measured to be $L_0 = L'_0 \cdot \sqrt{1-v^2/c^2}$. It is Lorentz-contracted.
Their derivation may have unnaturally exchanged various things, $S$ with $S'$, and they wrote the final relationship in the inverted way so that it looks like a "length dilatation", but the actual content of the derivation is right given their conventions.
But $t_1^\prime = t_2^\prime?$ since in $S^\prime$ the ends of the rod are at rest in that system and therefore can be measured simultaneously in that system.
You can't leave the two time endpoints the same. At time $t_{1}$, you take $L = x_{2}-x_{1}$. Now, take some time $t_{1}^{\prime}$. At this time, $x_{2}^{\prime}$ and $x_{1}^{\prime}$ are well-defined, and you have $L^{\prime} = x_{2}^{\prime} - x_{1}^{\prime}$. But, if $(t_{1},x_{1})$ is the same event as $(t_{1}^{\prime},x_{1}^{\prime})$, this will, as you right intuit, mean that $t_{2}^{\prime},x_{2}^{\prime}$ is a different event than $(t_{2},x_{2})$, because the time coordinates will label different times.