Script affecting all prefabs

Im currently working on a top down shooter, and right now I’m working on making the shooting work. I have the bullet shoot when the left mouse button is pressed, and the bullet should go to the mouse. The only issue is, if I move the mouse, the bullet also moved to go towards the new position.

Bullet Movement Script (What makes the bullet go to the mouse):

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

public class BulletMovement : MonoBehaviour {

    public float lifetime;
    public float speed;
    private Vector2 targetPos;
    public GameObject bullet;
	
	// Update is called once per frame
	void Update () {
        lifetime -= Time.deltaTime;
        targetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        bullet.transform.position = Vector2.MoveTowards(bullet.transform.position, targetPos, speed * Time.deltaTime);

        if(lifetime <= 0.0f)
        {
            Destroy(bullet);
        }
	}
}

Bullet Shooting Script (What makes the bullet appear):

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

public class PlayerShooting : MonoBehaviour {

    public GameObject bullet;
    public GameObject player;
    private Vector2 playerPosition;

    // Update is called once per frame
    void Update () {
        playerPosition = new Vector2(player.transform.position.x, player.transform.position.y);

        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log(playerPosition);
            Instantiate(bullet, playerPosition, Quaternion.Euler(0, 0, 0));
        }
	}
}

yes this will happen because you have written movement code in update method and target position is also in update so as you move mouse target position get changes and the new value pass to target in moveToward what you have to do is get the position ones only when player click or press button get value or position and pass that value and remove target line from update. write it down in playerShooting script. inside if ().