It's akin to firing and suing a carpenter because he used skills he developed on the job to build a nice rocking chair for the local community center.
While I'm totally on your side of this argument, I think this example is particularly interesting. Everyone except the employer sees a carpenter being charitable. The employer sees the carpenter making a chair of similarity to what they sell. So now the community center no longer purchases a chair from the employer.
Basically, I can see the employers side of the argument if the employee contributes to a competing open source project. Such as an MS Office developer contributing code to Open Office. Not sure if I agree in punishing them, but surely you see why this happens.