If you are not a Canadian citizen or permanent resident, you need a work permit to work legally in Canada.
Generally, you need to apply for a work permit from Immigration, Refugees and Citizenship Canada (IRCC) or a Canadian visa office before you come to Canada.
There are many types of work permits which have different conditions attached to them. They could be an employer specific work permit, an LMIA exempt work permit, or an open work permit.
Note that there are special work permits for some kinds of workers. For example, there are special work permit programs for caregivers, business people and agricultural workers.