There are two reasons why the Queen is mentioned in Canada’s Riot Act. Both of these reasons have to do with the fact that Canada is officially a constitutional monarchy whose roots are in the British (and, in Quebec, the French) monarchy.
The current Riot Act in Canada is based on a law that was passed by the Parliament of Great Britain in 1715. At that time, parts of the area that is now Canada were under British rule (other parts were still under the control of native peoples). At that time, Britain was truly a monarchy, so naturally they would have put in their Riot Act the wording “Her Majesty the Queen charges and commands…” (which would, at that time, have said “His Majesty the King” as the UK was then ruled by King George I. So, one reason that the law refers to the Queen is that it comes from an English law.
The other reason the law refers to the Queen is that Canada is, even today, officially a constitutional monarchy. While Queen Elizabeth II is best-known as the Queen of England, she is also the Queen of Canada. She is the official head of state of Canada. This is because Canada is still part of the Commonwealth of Nations (formerly the British Commonwealth) and continues to have the English sovereign as their sovereign. This has come about because Canada, unlike the United States, did not completely break away from the British Empire. Instead, Canada was given status as an autonomous Dominion in 1867, remaining part of the Empire while gaining self-government. Today, Canada is completely independent from the UK, but it still retains its connection to Britain in the form of their shared monarch. Because their official head of state is Queen Elizabeth II, their Riot Act continues to refer to the Queen.