Player gets stuck into object after collision

Hi, my player gets stuck into an object when it collides with it. The player has a rigidbody and the object only has a box collider. When I move the player it has a kind of blocky movement and I want it that way but when it collides with an object it gets stuck Please help me because I’m new to unity and I’ve been stuck on this for weeks. (Here is the script attached to the player)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

	float speed = 2.0f;
	Vector3 pos;
	Transform tr;
	
	void Start() {
			    pos = transform.position;
			    tr = transform;
		}
		 
	void Update() {
			 
			     if (Input.GetKey(KeyCode.D) && tr.position == pos)
				     {
			pos += Vector3.back;
				     }
			     else if (Input.GetKey(KeyCode.A) && tr.position == pos)
				     {
			pos += Vector3.forward;
				     }
			     else if (Input.GetKey(KeyCode.W) && tr.position == pos)
				     {
			pos += Vector3.right;
				     }
			     else if (Input.GetKey(KeyCode.S) && tr.position == pos)
				     {
			pos += Vector3.left;
				     }
			 
			     transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed);
		}  
		 
	}

If your are using RigidBodies on your player use:

RigidBody.Move ()

Or instead of Vector3.MoveTowards use Vector3.Lerp

transform.position = Vector3.lerp (transform.positon, transform.position + transpositionVariable * Time.deltaTime * speed, 1f);

@Cornelis-de-Jager I have a new question could you please answer it? Check my account