Machine Learning: Why do the error in cost function need to be squared?
The simple answer is that it's conviences rather than necessities.  You're more than welcome to take the absolute value and in many cases it may be better to do so.  Squaring a function makes the math a bit happier and easier and for proofs has desirable properties.  While you can basically do the same proofs with an absolute value function, you may have to handle certain edge cases and just amounts to more writing.