If you add something to one side of an equation and take it off at the same time, you haven't changed its value. The 4 was added to complete the square and then subtracted at the same time to preserve the original value of the right hand side of the equation.
Look at it this way.
First, factor out a 2 to allow the leading coefficient to be 1. Do nothing with the 7.
Next, complete the square that you have started in parentheses. You know how to do that. Take half the coefficient of x (which is 2), square it (that makes 4) and add it to complete the square. Since we've put the 4 inside the parenthesis, we have infact changed the expression by a factor of 2 times 4 or 8. We must subtract 8 from 7 to keep everything as it was before.