Press and hold a button for 2 seconds and it flashes

not sure how your button is wired because the code only does something when the pin is HIGH. conventionally, the pin is configured as INPUT_PULLUP and connected to ground thru the button. pressing the button pulls the the input LOW

don't see where estadoboton1 is defined how it would be set HIGH and how it would ever be be set not to HIGH in the while loops

        while(estadoboton1 == HIGH) {
            time2=millis();
            stateboton1= digitalRead(button1);
        }

considering above, how is time2 set?

in general, when testing for timed button presses, the code needs to capture when the button is pressed, if some max button press time has been exceeded while the button is pressed and when it is released before the max time occurs.

consider the following which compiles but is untested. i hope is demonstrates the above comment

int pinBut =2;
int pinLed = 4;

byte butLst;

unsigned long msec;
unsigned long time;
unsigned long ledTime;

// -----------------------------------------------------------------------------
#define BlinkPeriod 250
enum { Off = HIGH, On = LOW };

enum { LedOff, LedOn, LedBlink };
int ledState = LedOff;

void
led (void)
{
    switch (ledState) {
    case LedBlink:
        if ( (msec - ledTime) > BlinkPeriod)
            digitalWrite (pinLed, ! digitalRead (pinLed));
        break;

    case LedOn:
        digitalWrite (pinLed, On);
        break;

    case LedOff:
    default:
        digitalWrite (pinLed, Off);
        break;
    }
    
}

// -----------------------------------------------------------------------------
void loop () {
    msec = millis ();

    led ();

    byte but = digitalRead (pinBut);
    if (butLst != but)  {
        butLst = but;

        if (LOW == but)     // pressed
            time = msec;

        else  {             // button released
            if (time)  {    // 3000 not exceeded
                if ( (msec - time) > 2000)
                    ledState = LedBlink;
                else
                    ledState = LedOn;
                time = 0;
            }
        }
    }

    // turn LED off as soon as time > 3000 w/o waiting for button release
    if (time && (msec - time) > 3000)  {
        time = 0;
        ledState = LedOff;
    }
}

// -----------------------------------------------------------------------------
void setup (){
    Serial.begin (9600);
    pinMode (pinBut, INPUT_PULLUP);
    butLst = digitalRead (pinBut);
    pinMode (pinLed, OUTPUT);
}