How to fix this code so instead of having to hold button to change led, you can press?
instead of changing every time the buttonState == HIGH, change it when the button state was LOW the previous time but HIGH now:

buttonState = digitalRead(buttonPin);
if (oldButtonState != buttonState &amp;&amp; buttonState == HIGH) {
    //...
}
oldButtonState = buttonState;


However keep in mind contact bounce. Which can result in multiple transitions being detected. Most solutions for that set a minimal delay between handling transitions, dropping all others detected.