weird results

hello,
i have the following problem:
//after saving this c# file and starting the programm the first time the result of the
//_arrayOfButtons[n].GetComponent().anchoredPosition is (0.0, 0.0)
//if i start the programm a second time the result ist correct displayed with (100.0, -375.0)
//if i compile this program, the result is (0.0, 0.0)

i dont know where i made a mistake. thanks for reading and helping.

using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class UIController : MonoBehaviour {
    public string wantedNormalColor;
    public int howMuchDarkerOrBrighter;
    public int wantedFontSize;
    public Button[] _arrayOfButtons;
    public GameObject[] _arrayOfBottomButtonPanels;
    public GameObject[] _arrayOfBottomButtonPanelsPanels;
    private string wantedhighlightedColor;
    private string wantedpressedColor;
    private Color normalColor;
    private Color highlightedColor;
    private Color pressedColor;
    private Color selectedColor;
    private Button button;
    StringFromColor stringFromColor;

    void Start() {
        Recolor();
        TransformBottomButtonPanels();
        TransformBottomButtonPanelsPanels();
    }

    private void TransformBottomButtonPanelsPanels() {
        for (int i = 0; i < _arrayOfBottomButtonPanelsPanels.Length; i++) {
            string buttonname = GetFirstName(_arrayOfBottomButtonPanelsPanels) + "_Button";
            for (int n = 0; n < _arrayOfButtons.Length; n++) {
                if (_arrayOfButtons[n].name == buttonname) {


                    //after saving this c# file and starting the programm the first time the result of the
                    //_arrayOfButtons[n].GetComponent<RectTransform>().anchoredPosition is (0.0, 0.0)
                    //if i start the programm a second time the result ist correct displayed with (100.0, -375.0)
                    //if i compile this program, the result is (0.0, 0.0)


                    Debug.Log(_arrayOfButtons[n].name + " is on anchoredPosition: " + _arrayOfButtons[n].GetComponent<RectTransform>().anchoredPosition);
                    if (_arrayOfButtons[n].GetComponent<RectTransform>().anchoredPosition.x < _arrayOfButtons[n].GetComponent<RectTransform>().sizeDelta.x) {
                        _arrayOfBottomButtonPanelsPanels.GetComponents<RectTransform>()[0].anchoredPosition =
                        _arrayOfBottomButtonPanelsPanels.GetComponents<RectTransform>()[0].sizeDelta / 2 +
                        new Vector2(_arrayOfBottomButtonPanels[0].GetComponents<RectTransform>()[0].sizeDelta.x, 0);
                    }
                    else {
                        _arrayOfBottomButtonPanelsPanels.GetComponents<RectTransform>()[0].anchoredPosition =
                        _arrayOfBottomButtonPanelsPanels.GetComponents<RectTransform>()[0].sizeDelta / 2 +
                        new Vector2(_arrayOfBottomButtonPanels[0].GetComponents<RectTransform>()[0].sizeDelta.x / 2, 0);
                    }
                }
            }
            _arrayOfBottomButtonPanelsPanels.SetActive(false);
        }
    }
    private void TransformBottomButtonPanels() {
        Vector2 newPosition = new Vector2(0,50);
        for (int i = 0; i < _arrayOfBottomButtonPanels.Length; i++) {
            _arrayOfBottomButtonPanels.GetComponents<RectTransform>()[0].anchoredPosition = _arrayOfBottomButtonPanels.GetComponents<RectTransform>()[0].sizeDelta / 2 + newPosition;
            _arrayOfBottomButtonPanels.SetActive(false);
        }
    }

    private void Recolor() {
//...........
    }

    private ColorBlock ChangeButtonColor(Button button, Color normalColor, Color highlightedColor, Color pressedColor, Color selectedColor) {
       //...........
    }

    private Color ChangeButtonTextColor(TextMeshProUGUI tmpUGUI, Color newTextColor) {
          // ....
    }

    private string GetFirstName(GameObject gameObject) {
        char a = '_';
        string result = "";
        string zwischenspeicher;
        zwischenspeicher = gameObject.name;
        for (int i = 0; i < zwischenspeicher.Length; i++) {
            if (a != zwischenspeicher) {
                result += zwischenspeicher;
            }
            else break;
        }
        return result;
    }
}

please always post code with the code tags, otherwise its hard to follow it once the indents are gone

Thx for the hint. Now it should display correctly.