yea but they both technically made 2 pair. You take the best 5 card hand out of your 2 and the 5 on the board even if it means you only play the 5 on the board.
This is one of the reasons bottom 2 pair is such a vulnerable hand. If the board pairs above your 2 pair then you are pretty screwed to a lot of hands