I have gotten this question before. It is confusing at first, is it not? Yet, it is Luke who says both things, so it is not likely that he contradicted himself. Here is what I have assumed is going on here. While Paul was on the road to Damascus he saw a great light and also heard a loud voice. Those with him certainly heard the sound, but for reasons we are not given, they were not able to understand the voices. Many times I have said to people, “I did not hear you,” when I did in fact hear them. In other words I heard the sound of them talking, but did not hear them clearly enough to understand what they said. “I did not hear you” often actually means I could not make out what you said, could you please repeat yourself. This is the explanation of the apparent contradiction. In Acts 9:7 they heard the sound, but were not able to make out what was said. In Acts 22:9, they heard a sound, but were not able to “hear” (understand) what was said. It is possible that God purposefully enabled Paul to understand the voice, and confused the hearing of the others there because the message was for Paul alone.
The other possible explanation is that Luke is just plain wrong one of the times, but since it was he who wrote both accounts, and even in the same document, this explanation is extremely unlikely.