No, Alaska did not ever belong to Canada. In 1867, the US bought Alaska from Russia during a period when the border had not yet been properly demarcated. After the unity of British Columbia under the new Canadian Confederation in 1871, the Canadian government wanted to start a survey to mark the border. The US government denied the request citing high costs for surveying an area that was sparsely populated.
There are two main reasons. First, Canada wasn’t its own country in 1867. Second, Great Britain controlled the Canadian colonies. Russia did not want to sell Alaska to its rival. After the Alaskan purchase, the United States and Canada had a long and bitter dispute. They couldn’t agree on where exactly the Alaskan border was. Eventually, the dispute was settled and Alaska’s 1,538-mile border with Canada was established. Alaska went on to become the U.S.A.’s 49th state in 1959.