Al-Baqarah Surah 178: “O you who believe! Retaliation for the murdered is ordained upon you: the free for the free, the slave for the slave, the female for the female. But if he is forgiven by his kin, then grant any reasonable demand, and pay with good will. This is a concession from your Lord, and a mercy. But whoever commits aggression after that, a painful torment awaits him.”
Without considering the context of the verse, the meaning given above is correct when the translation is made with the literal meaning. However, given the context, what is being said gains a different meaning. If you simply stick to the meaning of the word; we can’t answer to questions such as what if a free person kills another free person or if a man kills a woman, what happens then.
But considering the context, there is no problem. In as much as the verse literally says “free person is free, slave is a slave, woman is a woman”, when context is taken into account; it becomes « whether he is free, slave or woman; whoever kills, they are killed ». In other words, no one else can be killed instead of the one who killed another person.
In the pre-Islamic ignorance period, another person can be killed instead of the killer. For example, if the killer is from a powerful tribe, a slave of that tribe is killed instead of the killer.