Bayesian rule with three variables I have seen in many tutorials the following
$$P(y, w_1 | w_2) = P(w_1|y) P(y|w_2)$$
Can someone help me understanding this derivation?
 A: This would normally be the case for a network like this:
$$W_1 \\
\downarrow \\
Y \\
\downarrow \\
W_2$$
(or the reverse direction: $W_2\rightarrow Y\rightarrow W_1$)
The Chain Rule of probability gives us:
$$P(y, w_1 \mid w_2) = P(w_1\mid y,w_2) P(y\mid w_2) \qquad\qquad\qquad\qquad(1)$$
To see why this is true, see Graham's answer, or else use the definition of conditional probability to expand both sides:
\begin{align}
P(y, w_1 \mid w_2) &= \dfrac{P(y, w_1, w_2)}{P(w_2)} \\
& \\
P(w_1\mid y,w_2) P(y\mid w_2) &= \dfrac{P(w_1,y,w_2)}{P(y,w_2)} \cdot \dfrac{P(y,w_2)}{P(w_2)} = \dfrac{P(y, w_1, w_2)}{P(w_2)}.
\end{align}
Now the network tells us that $w_1$ is conditionally independent of $w_2$ given $y$. This means $P(w_1\mid y,w_2) = P(w_1\mid y)$ so $(1)$ becomes
$$P(y, w_1 \mid w_2) = P(w_1\mid y) P(y\mid w_2).$$
A: This is not generally true.   Only in the case where $y\subseteq w_2$ , does then $\mathsf P(w_1\mid y,w_2)=\mathsf P(w_1\mid y)$.
As long as we are not dealing with zero measure events, then:
$$\begin{align}
\mathsf P(y, w_1\mid w_2) & = \dfrac{\mathsf P(y, w_1, w_2)}{\mathsf P(w_2)}
\\[1ex] & = \dfrac{\mathsf P(w_1\mid y, w_2)\,\mathsf P(y, w_2)}{\mathsf P(w_2)}
\\[1ex] & = \mathsf P(w_1\mid y, w_2)\,\mathsf P(y\mid w_2)
\\[3ex] & = \mathsf P(w_1\mid y)\,\mathsf P(y\mid w_2)
\end{align}$$
