Collder2D with 2 parametars?

Okay so I get this in the log:
Script error: OnCollisionEnter2D
The message must have 0 or 1 parameters.
The message will be ignored.

Can I make the OnCollisionEnter2D with 2 parametars?

private bool playerSwitchedSide;

    void OnCollisionEnter2D (Collider2D rightWall, Collider2D leftWall)
    {
        if (rightWall.gameObject.tag == "Right wall")
        {
            playerSwitchedSide = true;
        }
        else if (leftWall.gameObject.tag == "Left wall")
        {
            playerSwitchedSide = false;
        }

No, OnCollisionEnter2D can only take 0 or 1 parameters and it must be a Collision2D, not a Collider2D. If the object collides with multiple objects, Unity will call upon OnCollisionEnter2D several times. Each time there will be information about the “current” collision found in the Collision2D parameter.

The parameter [Collider2D] is the collider component of the gameObject you hit.
You should check if that single parameter is right or left wall:

private bool playerSwitchedSide;

    void OnCollisionEnter2D (Collision2D coll)
    {
        if (coll.gameObject.tag == "Right wall" ||  coll.gameObject.tag == "Left wall")
        {
            playerSwitchedSide = true;
        }

I think this is a bit off about your question, but if I understand you want to check what side you are colliding. You can use this :

 void OnCollisionEnter2D(Collision2D  collision)
     {
         Collider2D collider = collision.collider;
 
         if(collider.name == "Wall")
         {
             Vector3 contactPoint = collision.contacts[0].point;
             Vector3 center = collider.bounds.center;
             bool right = contactPoint.x > center.x; 
             bool top = contactPoint.y > center.y;
         }
     }

Thank you to all of you who replied… I found other way… I attached two different scripts to the both walls and called the functions from other script… Thank you again…