Being loving does not mean that people can’t be punished. A parent who loves his child with an incredible depth of love will discipline his child when needed. In fact, to not discipline the child when it is needed would not be loving at all as that would be an encouragement to the child to rebel and do wrong.
But consider that God is not only love (1 John 4:8). God is also just (Isaiah 30:18), holy (1 Pet. 1:16), and righteous (Dan. 9:14). He must punish the sinner who has broken His law and who has refused to receive the atoning sacrifice by which the sinner can escape God’s righteous judgment. If He did not, then He would be approving of evil and would not be just.
It is not a contradiction to say that God both loves us and punishes us. Both are within the divine character of God’s greatness, and though we may not understand or even appreciate how God can love so great and also punish so permanently, we must accept the fact that God, who is the righteous judge, loves us (by dying for us on the cross) and judges us when we refuse to receive His love and sacrifice.