Problem understanding non blocking delay via millis()

You need to put all the separate acitivities separately in loop(), not nested.

One activity is detecting when to turn the LED on.

Another is detecting the time-out for turning the LED off.

These "tasks" should both run everytime through loop - then they are
effectively independent and run in pseudo-parallel.

loop() should always look like:

void loop ()
{
  if (<condition1>)
    task1 () ;
  if (<condition2>)
    task2 () ;
  if (<condition3>)
    task3 () ;
  ....
  ....
  if (<conditionN>)
    taskN () ;
}

Then be careful to code up the conditions so they assume nothing - for instance
a test for timing-out the LED would be something like

  if (LED_is_on() && millis() - led_time >= led_timeout)
    cancel_LED() ;

Note the hiding of detail in clearly named functions - this is always
a good idea.