When I first read the short story A&P back when I was a teenager myself, I remember feeling very identified with Sammy because I felt that I would have done the same thing if I had been a boy. Think about this: The main character is in a bit of an embarrasing situation by being behind the counter while other kids his own age are out there enjoying their break. This shows that he had a need for working, whereas the girls did not. Because of his age, he probably felt uncool in front of them, and that was the reason why he opted to sympathize with them: So that he looks less cheesy and more cool in front of his peers.
Sammy definitely has sympathy for the girls and also seems to identify with them in terms of the way that they are so brave and bold in rejecting the norms of society by coming into the supermarket with nothing but a bathing suit on. It is sympathy for the girls that makes him quit his job as a form of showing them how much he identifies with them and, in a sense, envies their willingness to "go against the flow of society."
I don't believe Sammy has sympathy for the girls. He seems to be motivated by a need to impress the girls with his bravado. His motivation to "defend" them is not rooted in good intentions, in my opinion. In the story, he watched the girls as they are shopping and is very aware of what they are doing as the story progresses. When he confronts his boss about his actions towards the girls, he wants to make sure the girls see him do it. They do; however, they leave afterwards and are not waiting on him after he leaves the store, which makes him realize that he perhaps made a hasty decision to quit his job.