There are two possibilities.
One is that your employer has the type of 401k plan where an employee is automatically enrolled UNLESS you sign something saying that you do not wish to participate. The fact that this happened at one year's employment leads me to believe that this is the more likely scenario. If this is the case, then they are 100% correct that the only way you can get that money back is to leave the company. It is not only legal; it is Federal law.
The other possibility is that it legitimately was a clerical error, in which case most companies I know would reverse the deduction and return the money to you. This IS a violation of the law, but one that would probably pass muster with an audit (and make no mistake; they WILL be audited) if there is clear evidence of the error. However, since it technically IS a legal violation (once the money is in the fund, it's supposed to stay there!) I don't know of any way you can force them to do so.