There is no accord allowing free movement of people between the USA and Canada. Neither country has visa requirements for short term entry, but there is no agreement (like the Schengen accord in Europe) to allow people to cross the border [source]
As such, both the USA and Canada are free to close the border for any or no reason, and there is no requirement in treaty to allow foreign nationals to enter a country to travel to an exclave.
There is an agreement for the USA to pay Canada to maintain and upgrade the Alaska Highway, and there is an agreement to share immigration information, but nothing in these agreements guarantees Alaskans the right to enter Canada for the purpose of travelling to and from the contiguous 48.
So this is essentially a case of "good neighbourliness". No doubt if this became a significant cause of new infections of COVID19, the situation would change.