It’s an ugly picture but an easy answer.
The Bible is a book of God’s word. And as such, it means that the Bible is inerrant; it contains no errors from God. But the Bible is also a history book. Not an in-depth history book, but where it touches on history, as well as geography and science, it is accurate.
This verse is a case of history. This verse is in a series describing a period of time when Samaria is under siege. The siege has gone on for so long that the city has run out of food. And people are doing detestable thing. Eating and drinking waste. And they also ate their own people. In this case, 2 women had eaten one of their children and are fighting because the other woman will not give up her child for them to dine on.
The fact that this story is in the Bible is not a statement that God approves of cannibalism, it is there as a witness to history. It is an ugly scene. It is a shame to have to have it in the such a beautiful book of love. But to help show God’s love for us, He shows us the hideous side of sin.