Colliders not working

I’m not sure whats happening. When my player collider comes into contact with my boundary colliders it doesn’t teleport , the player, to the other edge of the screen.

public class boundaries : MonoBehaviour {
    public Transform player;
    void OnCollisionEnter2D(Collision2D coll)
    {
        player.position = new Vector2(player.position.x * -1, player.position.y * -1);
    }
}

Do you have correctly used the good type of colliders. Are you sure you do not have to use trigger instead?

What do you mean good type of colliders? I am using a capsule collider 2d on the player and edge colliders 2d for the boundaries.
I tried onTriggerEnter2d but it did not work. This is the script with onTriggerEnter2D.

public class boundaries : MonoBehaviour {
    public Transform player;
    void OnTriggerEnter2D(Collider2D other)
    {
        player.position = new Vector2(player.position.x * -1, player.position.y * -1);
    }
}