When i rotate transform to x value > 90, Euler Angle y, z auto set = 180

I have problemt with rotation in unity. I want limit transform rotation with logic :
transform.localEulerAngles.x= transform.localEulerAngles.x> 180 ? transform.localEulerAngles.x- 360 : transform.localEulerAngles.x;
transform.localEulerAngles.x= Mathf.Clamp(transform.localEulerAngles.x, xMin, xMax);
But when i rotate transform to x value > 90, Euler Angle y, z auto set = 180, and x value auto set = 180 - x value, so my logic is incorrect, pls tell me how to fix it