When you rotate an image in your phone or on your computer (by right-clicking or going into the image options and selecting "Rotate Right" or w/e), the device is not editing the image to rotate it 90 degrees. It's just adding a little metadata tag that tells devices loading the image "display this, but rotate it 90 degrees".
Lemmy scrapes off metadata as a privacy concern, since this also holds personal and location data. There have been a few medium-profile events of internet stalkers getting location data off of women's selfies and going straight to their homes.
I'm not sure if there's a simpler solution, but opening the image in an image editor and saving it again should remove the metadata tag and save it as an actual, upright image. However, this is a problem that the devs should fix - platforms like Discord also shave off metadata, but know enough to leave the orientation data intact.