I'm trying to resize all images in a directory using this bash script :
for i in *.jpg; do
    printf "Resize $i\n"
    convert "$i" -resize 336x336 "$i"
done
But when the resize is complete, I get 336x252. How can I resolve this ?
When the ImageMagick convert utility resizes an image, it retains the image's aspect ratio without exceeding the size limits that you specify.
If you have an image that is 48x36 pixels big (or 480x360 or something with the same 4:3 aspect ratio) and you ask convert to resize it up to 336x336 pixels, then 336x252 is the biggest it will be able to make it while still keeping its aspect ratio.
You can force convert to ignore the image's aspect ratio by using '336x336!' as the option argument to the -resize option.
This is documented in the ImageMagick command-line documentation, in the section about Image Geometry.
In your loop, you are using printf in the wrong way.
Do this instead:  printf 'Resizing %s\n' "$i"
The first argument to printf should always be a static format template, and the remaining arguments should be data that should be used to fill out the template.
See also: ShellCheck problem code SC2059 ("Don't use variables in the printf format string").
336x252?convertpreserves aspect ratio by default - you should be able to override that (i.e. produce a distorted output image) by adding!(suitably protected from your shell of course ex.-resize 336x336\!). See for example imagemagick crop images to specific aspect ratio?