A possible motivation for what $Y$ represents is: given a graph with $n$ vertices and no edges, each vertex in the graph is painted red with probability $p$. After all vertices are either painted red or not painted, an edge is drawn between every $2$ red vertices. let $Y$ represent the number of edges in the graph.
What i don't understand is: if i were to think, what is the probability that a certain edge appears in the graph, then i would realize that the edge exists iff the two vertices it connects are painted red; and this happens with probability $p^2$. Then if i were to mistakenly consider the drawing of each edge as an independent trial with probability of success equal to $p^2$ (that is the edge being considered is drawn) then i would find that $E(Y)={n \choose 2}p^2$ but clearly the trials in which each edge is either drawn or not drawn are not independent of one another.
Thanks in advance.
Your intuition is correct.
Remember that we have linearity of expectation regardless of independence.
If it helps, you can introduce indicator variable $I_e$ for each edge where it takes value $1$ if there is an edge and $0$ otherwise.
then we have $Y=\sum_e I_e$, hence we have $E[Y]=\sum_e E[I_e]$. Note that there is no interaction terms like $I_{e_1}I_{e_j}$ in our expression.