In the maximum cut problem, we want to maximize the number of edges with distinctly colored endpoints by coloring vertices with 2 colors, say red and blue. By flipping a fair coin for each vertex, we can show that the 2-coloring cuts at least $m/2$ edges, where $m$ is the number of edges in the graph.
Now, I'm reading these notes (Section 11.2.1, page 223) on maximum cut. In particular, I'm interested in the probability that the described coin flipping procedure gives us a cut with at least $m/2$ edges cut.
The analysis is given on page 223, where $p$ is the probability that $X \geq m/2$, where $X$ is a random variable for the number of edges cut. I have a hard time understanding how $E[X]$ can be written in the way it is written (both the claimed equality, and the inequality that follows): what is the justification for writing this (ultimately) as $(1-p)\frac{m-1}{2} + pm$?
(Another example is here on the slide titled "Example 1: Large Cut (4)", where my question is exactly "why??" shown on the slide as well).