Going through these lecture notes, I have seen two representations of the Dirac comb. The first one is obtained through the complex Fourier series of a periodic functions $f(x)= f(x+L)$ (see the case of $L=2\pi$ in page 27) and in reads as \begin{equation} \frac{1}{L} + \frac{2}{L} \sum_{n=1}^\infty \cos (\frac{2n \pi (z-z')}{L} ) = \sum_{m=-\infty}^{\infty} \delta(z-z'-mL) \qquad\qquad (I) \end{equation}
The second representation comes from the sine representation of functions that satisfy Dirichlet boundary conditions (see page 32 of the notes) and reads as \begin{equation} \frac{2}{\ell} \sum_{n=1}^\infty \sin(\frac{n\pi z}{\ell}) \sin(\frac{n\pi z'}{\ell}) = \sum_{m=-\infty}^\infty \delta(z-z'-2m \ell). \qquad\qquad (II) \end{equation}
I am trying to see the equivalence of the l.h.s of these relations, by starting from the l.h.s of the second one and setting $\ell=L/2$ and then using trigonometric formulae. Here is what I get: \begin{align} \sum_{m=-\infty}^\infty \delta(z-z'-m L) &\stackrel{(II)}{=} \frac{4}{L} \sum_{n=1}^\infty \sin( \frac{2n\pi z}{L}) \sin(\frac{2n\pi z'}{L})\\ &= \frac{4}{L} \sum_{n=1}^\infty \frac{1}{2} \left[ \cos (\frac{2n\pi (z-z')}{L}) - \cos (\frac{2n\pi (z+z')}{L}) \right]\\ &= \frac{2}{L} \sum_{n=1}^\infty \cos (\frac{2n\pi (z-z')}{L}) -\frac{2}{L} \sum_{n=1}^\infty \cos (\frac{2n\pi (z+z')}{L}) \\ &\stackrel{(I)}{=} \sum_{m=-\infty}^\infty \delta(z-z'-mL) - \sum_{m=-\infty}^\infty \delta(z+z'-mL) \end{align}
which seems to be a contradiction. Am I doing something wrong here, or does this mean these two representations are not equivalent?
Although you've not said what you yourself mean by "equivalent" exactly, you are correct that, as tempered distributions for example, the two infinite sums are not equal.
In some ways, it's even worse than that: the second version, using $\sin(\pi nx)$'s, makes best sense as a functional on smooth functions (etc) vanishing at endpoints. A fundamental issue is that these functions with odd $n$ are being construed as $1$-periodic, even though they are only $2$-periodic, and the $1$-periodic extensions are not smooth (they have corners!).
Some troubles are already visible if we just look at the two families as orthogonal bases for $L^2[0,1]$. The $\sin(\pi n x)$ with $n$ odd are not finite sums of the others. And the expansion in terms of the $\sin(\pi nx)$'s of smooth $1$-periodic functions $f$ does not converge very well if $f(0)\not=0$. The expansion of $f(x)=1$ already has this problem.
The latter issues mean that conditions for convergence of those series in any strong sense is problemmatical. Taking duals, the characterizations of periodic distributions by such series expansions are not quite comparable. Perhaps amusingly, computing somewhat naively at the level of expansions of distributions easily overlooks that disconnect, leading to the seeming paradox of your computation. Your first expression is valid for the Dirac comb as a distribution, that is, a continuous functional on smooth functions. The second version (as your computation shows) cannot be that, although it will agree (for example) on smooth functions vanishing to infinite order at integers.
EDIT: in response to comments... Yes, indeed, in an $L^2$ sense the Dirichlet boundary conditions (can't really be on $L^2$, since pointwise values don't quite make sense... ominous) give the $\sin(n\pi x)$ expansion, and Neumann boundary conditions give the analogous cosine expansion. And both (as well as the "smoothly periodic") give orthogonal bases for $L^2$. Check.
But at the point that we are interested in smoothness properties of functions, and in how well their various expansions reflect this (meaning that the finite partial sums of the expansions converge to the function in a stronger topology reflecting derivatives...), the happy-naive boundary-value story is inadequate.
Again, observe that the periodicized versions of $\sin(\pi nx)$ and $\cos(\pi nx)$ are not smooth at the "joints" (EDIT-EDIT: for odd $n$). Bad omen.