So, this is a Feed Forward Loop. It is a regularly occurring subgraph of a huge random graph.
In the case of X,Y,Z being any nodes, we have that the mean number of times that a subgraph G appears is : $$<N_G> \approx N^n \ p^g$$ (the number of ways of choosing a set of n nodes out of N, namely $N^n$ for large networks*, multiplied by the probability to get the g edges in the appropriate places, each with probability p). $$=> \ <N_{FFL}>=N^3\ p^3 $$
What is the mean number of such subgraphs, but with Z being an output node, namely a node with no child ($<N_{FFL}'>$)?
* because there are N ways of choosing the first node, times $N-1 \approx N$ ways of choosing the second etc.
If Z is an output node then in the subgraph of the FFL, there are 2 input nodes and one output node. Also, there is 1 input link and 2 output links.
Now according to the formula, we have 2 ways to choose the input nodes, times 2, because we can switch between them. That means ${Nin \choose 2}\bullet 2$. About the probabilities, we have $p_{out}^2$ times $p_{in}$, since we have 2 output edges with probability $p_{out}$ each and one input edge with $p_{in}$.
Therefore, we get that: $$ <N_{ffl}> = 2 {Nin \choose 2}\ N_{out}\ p_{out}^2\ p_{in} $$