If it is a vector, resize it as a vector.
If it is a raster image, you need to use exact multiples. But you need to consider some more things.
If your image is let's say 500x500px you can only resample it as 250x250, Or you can scale it up to 1000x1000px or 1500x1500px.
Only use the nearest neighbor method. If you need to assemble it on let's say a banner, resample it separately and then copy and paste it into your canvas.
Scaling up to a bigger size could handle a small level of imperfection, Let's say you could scale it up to 1900 instead of 2000, but for smaller sizes, you need to count and measure the squares.
Each QR has a specific number of squares, plus the safe area is a multiple of those squares. Count them before reaching a smaller number than that.
One "rule" is that you do not "force" your QR to be the minimum size. So each square should NOT be only 1 px, but let's say a minimum of 3-4 pixels each.
An additional note based on the comments.
Although vector files are not made by pixels, some view modes are based on a grid to preview the alignment when exported to a raster file.
So if the shape is not perfectly aligned with that "invisible" grid, if the origin of the shape is not perfectly aligned with the origin of the file it might render that small "alias" meaning that the black squares start to "tint" the next pixel.
One way to avoid it is to resize the canvas to perfectly match the dimensions you need, and also the shape, and align them to fit each other.
And a workaround would be to export it as it is and then apply some level adjustment, or change it to black-and-white color mode.