The rotation is applied first around the z-axis, then around the x-axis and last around the y-axis. This means that rotating around the x-axis results in a rotation around the original y-axis aswell.
The easiest way to achieve what you want is probably to parent the object to another game object, and rotate the parent and child around the two axes separately.
That way the order of rotation doesn't matter. You need to set the localTransform of the child instead of the transform to get the correct behavior.
You might also want to keep the two angles in variables, and set the rotation using localTransform.rotation = Quaternion.Euler(x,y,z)
, instead of applying the rotation to the current transform, because that will be more robust against rounding errors and the state is easier to inspect and control.
Example (untested):
baseRotation += Input.GetAxis ("Horizontal");
barrelRotation += Input.GetAxis ("Vertical");
turretBase.localTransform.rotation = Quaternion.Euler(0, 0, baseRotation);
turretBarrel.localTransform.rotation = Quaternion.Euler(barrelRotation, 0, 0);