I cannot say I have the absolute truth, though I do have an idea about it. Again, please do forgive me if I am wrong.
In these two verses we must see the context. As we know, many times in the past Israel had trouble with Babylon; their people were captured and taken prisoners, Babylon destroyed their temples, and their men were killed, in the times of Daniel the youngsters were even taken prisoners and taught babilonic religion. However, at the same time, Israel is known for having corruped their ways; many times, even in the times of Moses, Israel adopted pagan religions and gave themselves to idolatry, they rejected the law of God and accepted the profanation of His Temple.
In Psalms 137:9 is talking about Babylon, if we see the whole chapter it is talking about how the hebrews remembered Zion with sadness, about how being in another kingdom they still missed their homeland, and in verses 8 to 9 it says how they wished for Babylon to pay for all they were suffering.
In Ezekiel 23, again, we must see the whole chapter. It says how God is talking to the prophet, telling him how there were two sisters (Samaria and Jerusalem, there is also a little bit of history in here, the country having been split in two at the time, the north and the south). Samaria, capital of Israel, got related to the assyrians and many other pagan kingdoms, adopting their culture and accepting idolatry. As such, it was attacked by many countries. Jerusalem, capital of Judah, even after seeing the consecuences of Samaria's fornication, still did the same as her, and even worse, adopting other countries' culture, idolatry and corrupting the Temple of the Lord, doing the same they did in the past. However, God gave Jerusalem a warning about what their punishment will be; they will be attacked by the same countries they got related to, they will suffer at the hands of those who they shared idolatry with, because they followed after Samaria's steps. Psalms 137 shows the consecuences of Israel's actions, how they longed for their homeland after having been taken captive by Babylon because of their idolatry.
In other words, those two chapters are not exactly contradictions, but rather cause and consecuence. Psalms 137 shows what the people from Israel were suffering for what is described in Ezekiel 23.
I can't say if I am correct (it would be too pretentious on my part), but that is what I know. I would write in more detail, but I don't have that much time and I'm on my cellphone, so yeah. I hope is the answer you were looking for, if not, I am sorry
.