camera rotation problem

i have a code that is supposed to allow the camera to rotate on the X and Y axis, however, whenever this happens, the Z axis is in movement despite not being mentioned in the code. the code is attached to the a cube which the main camera follows:

void FixedUpdate()
{
    
    if ( Input.GetKey("w"))
    {
        RB.AddTorque(horizontal * Time.deltaTime, 0, 0);
    }
    if ( Input.GetKey("s"))
    {
        RB.AddTorque(-horizontal * Time.deltaTime, 0, 0);
    }
    if ( Input.GetKey("a"))
    {
        RB.AddTorque(0, vertical * Time.deltaTime, 0);
    }
    if ( Input.GetKey("d"))
    {
        RB.AddTorque(0, -vertical * Time.deltaTime, 0);
    }
}

}

I have tried to do a few things, but nothing worked. I just want no movement on the Z axis. if this question has been asked and answered please direct me to it. and thank you for taking the time to read this

on inspector game object > rigidbody>Constraints>frezze rotations now check the z box
hope this will help
any way i don’t recommend to use .addtorque for rotate game object