Strange rotation caused by translation?

Here is the illustration of my problem:

I move player (red rectangle) towards some obstacle (player and obstacle have box colliders)and the player hits that obstacle. Then if I continue pressing the movement key and try to continue moving, then player starts to rotate around obstacle. How can I disable this rotation (I can’t use Freeze rotation in Rigidbody because my layer is able to rotate, I just don’t want this rotation around obstacles to happen)

Thank’s in advance

in CollisionEnter do Freeze rotation = true

in CollisionExit do Freeze rotation = false