The y axis of my fire_point randomly change for no reason, I need help

I wrote this really simple code to move an object and fire bullets with the mouse but when I try to separate the movement and the fire code there’s a weird bug where the y of the fire_point sometimes be wrong.

private Camera cam;
[SerializeField] private Transform fire_point;
[SerializeField] private GameObject bullet;

void Start()
{
    cam = Camera.main;
}

void Update()
{
    Vector3 worldPos = cam.ScreenToWorldPoint(Input.mousePosition);
    transform.position = new Vector3(worldPos.x, worldPos.y, transform.position.z);
    if (Input.GetMouseButtonDown(0))
    {
        Instantiate(bullet, fire_point.position, fire_point.rotation);
        Debug.Log(fire_point.position);
    }
}