How to make a smooth rotation?

Hello, I have a problem with the code. The problem is when I press either on left/right of the screen the character doesn’t rotate smoothly, but I also have a code where you press “A” or “D” and the character rotates smoothly. Can someone help me understand what I am doing wrong please?? My code:

transform.Rotate(0, 0, Input.GetAxis("Horizontal") * rotateSpeed); 
if (Input.GetMouseButton(0))
{
    if (Input.mousePosition.x > Screen.width / 2)
        transform.Rotate(0, 0, -rotateSpeed);
    else
        transform.Rotate(0, 0, rotateSpeed);
}
transform.rotation = Quaternion.Lerp(transform.rotation, transform.rotation, rotateSpeed * Time.deltaTime);

Thank you for you time

You are trying to lerp to the same position you are already in. Try this and let me know if there is anything you need explained.

private float desiredRot;
	public float rotSpeed = 250;
	public float damping = 10;

	private void OnEnable() {
		desiredRot = transform.eulerAngles.z;
	}

	private void Update() {
		if (Input.GetMouseButton(0)) {
		     if (Input.mousePosition.x > Screen.width / 2) desiredRot -= rotSpeed * Time.deltaTime;
		     else desiredRot += rotSpeed * Time.deltaTime;
		 }

		var desiredRotQ = Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, desiredRot);
		transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotQ, Time.deltaTime * damping);
    }