Did you check if the correct exif data is present? Normally, cameras don't rotate the data but place an EXIF attribute to let the viewer know how the data should be presented. If the viewer does not read the EXIF attribute or it is not present, the picture has the wrong orientation. So I would start by finding out if the EXIF data is actually present.
Nevertheless, this is stuff even LLMs know how to do correctly, so there's no excuse for Apple here.