https://en.m.wikipedia.org/wiki/List_of_North_Korean_missile_tests
North Korean missile tests "end" (stop being reported to the public) in late 2017. As you can see they already have missiles capable of reaching the US.
https://en.m.wikipedia.org/wiki/2017_in_North_Korea
The US relationship with North Korea reached a low at the end of 2017. Trump labeled North Korea as a sponsor of terrorism and placed sanctions on them. A week later NK launched a ballistic missile test.
US-NK relations continued to decline after the sanctions were ignored by China and Russia. NK was running low on supplies.
https://www.google.com/amp/s/www.foxnews.com/politics/us-oks-selling-japan-missiles-to-shoot-down-north-korean-missiles.amp
The US approved anti ballistic missile defense systems to Japan on Jan 9, 2018.
Jan 13, 2018: Hawaii receives a ballistic missile warning lasting about 40 minutes.
https://www.npr.org/sections/thetwo-way/2018/01/16/578283950/japan-also-sends-out-then-retracts-a-false-missile-warning
Jan 16, 2018: Japan issued a ballistic missile alert that was retracted in less than 10 minutes.
Based on the information it is likely that North Korea was goaded into attacking the US with its missiles. The first one definitely targeted Hawaii. The missile was most likely detected at launch and the warning was sent out.
Most missile defense systems work by shooting down ICBM's at or after they reach the highest point in their trajectory. That means it would take a few minutes before it could be shot down. Unclassified land based missile defense systems are located in California and Alaska. It's likely that there are submarine based systems near Hawaii as well. Either way it would take a few minutes to shoot down. Adding this time to the amount of time to it would have taken to confirm the ICBM destruction and the time to relay this info to the emergency broadcasting service would account for the 40 minute retraction time.
Three days later, the US and it's closest ally to NK, Japan, were ready and feeling confident about the defense system. When the missile launch was detected Japan initiated its emergency warning and launched a counter missile on behalf of the US (probably part of the deal which allowed them to purchase the defense systems). Since the defense missile was launched early in the ICBM's flight it was able to shoot it down fast. The confirmation of the destruction only took minutes and the emergency was retracted.