In a binomial experiment, each trial is independent and has the same probability of success. If the probability of success is 0.5, then the probability of failure is also 0.5, since they must add up to 1. If there are 2 successes out of 5 trials, then there are 3 failures. So the probability of 2 successes is 0.52, and the probability of 3 failures is 0.53. These need to be multiplied together. This becomes 0.55 = 0.03125. But there is more to be considered, namely, how many ways this can happen. The number of ways is the number of ways you can select 2 (successes) from 5 (trials), which is 5C2 = 10. This gets multiplied by 0.03125 to get 0.3125.
The general formula is P(X = x) = (nCx) • px • (1 - p)n - x