Oh... Oh! That's because on itch.io your game is embedded into an iframe of fixed size, that ignores any changes in the parent window. You're basically asking for a way to resize the iframe itch.io puts on your game page. That's quite different from resizing your canvas to fit the iframe. Open one of my games in a tab of its own, or click the full-screen button, and you'll see it resizes just fine.
Now, it might just make sense for the iframe itch.io generates for you to resize with the window... except the itch.io website is designed in a fixed 960px width -- it doesn't reflow. But it is an idea, and worth asking about. But for now, your code is actually working just fine, I suspect. It just can't do what you expect of it.