Just reset the Y position after the change like the following
void Update(){
//Code to move in any particular direction
transform.position = new Vector3(transform.position.x,FIXED_Y_VALUE,transform.position.z);
}
or don't change Y direction at all -
void Update(){
Vector3 newCameraPosition = transform.position + transform.forward * walkSpeed * Time.deltaTime;
transform.position = new Vector3(newCameraPosition.x,transform.position.y,newCameraPosition.z);
}