In the Wikipedia page for separation of variables an example is shown where the author derives
$$f(x) = \sum_{n = 1}^{\infty} D_n \sin \frac{n\pi x}{L}$$
as a sine series expansion of $f(x)$. They then state that multiplying both sides by $\sin{\frac{n\pi{x}}{L}}$ and integrating over $[0,L]$ produces
$$D_n = \frac{2}{L} \int_0^L f(x) \sin \frac{n\pi x}{L} \, dx$$
If I do these steps on paper then I would write
$$\int_0^L f(x) \sin \frac{n\pi x}{L} dx=\int_0^L\sum_{n = 1}^{\infty} D_n \sin \frac{n\pi x}{L}\sin \frac{n\pi x}{L}dx$$
Why does
$$\int_0^L\sum_{n = 1}^{\infty} D_n \sin \frac{n\pi x}{L}\sin \frac{n\pi x}{L}dx=\frac{D_n L}{2}$$
I think that this is because of the orthonormal bases.
$$\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}=1 ~~ \text{if $m=n$} $$ $$\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}=0 ~~ \text{if $m\neq n$} $$
But that would produce
$$\int_0^L\sum_{n = 1}^{\infty} D_n \sin \frac{n\pi x}{L}\sin \frac{n\pi x}{L}dx=D_n L$$
I'm confused why the Wikipedia page (and textbooks) write the coefficient as $\frac{2}{L}$.
Yes, you have the right idea of where this comes from, although it's not the case that $$\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}=1 ~~ \text{if $m=n$}$$
$$\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}=0 ~~ \text{if $m\neq n$}.$$
What you are really interested in is what the value of $$\int_{0}^{L}\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}\,dx$$ is, depending on whether $m=n$ or $m\neq n$. If $m = n$ we get $$ \begin{align*} \int_{0}^{L}\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}\,dx &= \int_{0}^{L}\sin^{2}\frac{n\pi x}{L}\,dx\\ &=\frac{1}{2}\int_{0}^{L}\left(1 - \cos\frac{2n\pi x}{L}\right)\,dx\\ &=\frac{1}{2}\left(x-\frac{L}{2n\pi}\sin\frac{2n\pi x}{L}\right)\Bigg|_{0}^{L}\\ &=\frac{1}{2}\left(L-\frac{L}{2n\pi}\sin 2n\pi\right)\\ &=\frac{L}{2}. \end{align*} $$
A similar argument using the product/sum identities yields $$\int_{0}^{L}\sin \frac{n\pi x}{L}\sin \frac{m\pi x}{L}\,dx = 0$$ in the case that $m\neq n$.