After collision my characher keeps moving left

if(Input.GetKey(KeyCode.A))
{
playerpos.transform.position += Vector3.left * speed * Time.deltaTime;

    }
    
    if (Input.GetKey(KeyCode.D))
    {
        playerpos.transform.position += Vector3.right * speed * Time.deltaTime;
       
    }
   
    anim.SetBool("run", true);

transform.translate moves without taking into account collisions. You need to use physics movement, not transform.translate. I suggest you watch a video on movement such as those in the learn.unity.com courses.