Rotation related problem (please help)

I’m new at making games in unity, that’s why I need help.

So I encountered a issue, while writing code for my prefab store shelves, which I wanted to rotate 270 degrees. Turns out, that shelves do what they want, and I don’t know why. (I’ve checked inspector and in some of them rotation was 90, some 360 and some 270) (prefab was dragged into the scene and default rotation was 0)
{
public float wantedRotation;

// Start is called before the first frame update
void Start()
{
    GameEvent.current.onActivateShelves += FirstRotate;
    GameEvent.current.ActivateShelves();

    wantedRotation = 0.0f;
}

// Update is called once per frame
void Update()
{
    if (wantedRotation > 360.0f)
        wantedRotation -= 360.0f;

    if (transform.rotation.eulerAngles.z <= wantedRotation || transform.rotation.eulerAngles.z >= wantedRotation + 3.0f)
    {
        transform.Rotate(Vector3.forward * (36 * Time.deltaTime));
        Debug.Log(transform.rotation.eulerAngles.z);
    }

}

public void FirstRotate()
{
        wantedRotation += 270;
}

I don’t get why you don’t just make the default rotation of the prefab 270 degrees, and then use it??

But if you insist on “rotating” a object in runtime:

For constant rotation:

    public float rotationSpeed;

    void Update()
    {
        transform.Rotate(new Vector3(0f, 0f, rotationSpeed) * Time.deltaTime);
    }

For Rotation at start:

    public float angle; //change to the degrees you want in inspector... (270 in your case)

    void Start()
    {
        transform.rotation = Quaternion.Euler(0, 0, angle);
    }