Icons typically store several different resolutions at once, like 16x16, 32x32, 64x64, 128x128, 256x256, and sometimes 24x24, 48x48, and so on. What you should do is make your icon file explicitly include each size you want. Depending on the tool it will be different.
In Imagemagick's convert command can do something like this:
https://www.reddit.com/r/learnpython/comments/fks3oc/autoscaling_ico_with_pyinstaller/
https://imagemagick.org/script/download.php#windows