Square (JPEG-like) artifacts are produced when images are enlarged by "Bicubic (smooth gradients)" interpolation. Their size depends on the size of the enlargement of image. If the enlargement is N*100% the artifacts have a size of NxN px, where N = 3,4,5, etc. If the enlargement is too large (1000% for example) artifacts will be lost in the blurry image. A good enlargement for observing artifacts is 400%. Artifacts are produced in both RGB and Grayscale mode.
(Resizing was done in Photoshop 22.0.1, but artifacts can also be observed in earlier versions of Photoshop.)
Other software that uses bicubic interpolation to enlarge images (Wolfram Mathematica or Affinity Photo) does not produce such artifacts (see below). In fact, there is minimal difference between Wolfram Mathematica's output and Affinity Photo.
Artifacts are not visible when "Bicubic Smoother (enlargement)" is used when enlarging images. However, this interpolation produces too blurry images compared to regular Bicubic interpolation.
Are these artifacts in "Bicubic (smooth grad.)" interpolation a side effect of some performance optimization in Photoshop, or is it a bug?
Update (2020-12-22): The description of the problem was supported by images. In images, a magnification of 1000% actually means enlarging the image using Photoshop nearest-neighbor scaling algorithm (i.e. the non-destructive algorithm) after bicubic resizing. The source image had a color depth of 24 bits. The difference in implementation between the bicubic algorithm of Photoshop and other programs is best observed by opening the above images in separate browser tabs (i.e. in full screen).