You probably didn't turn them upside down. Since the advent of digital cameras, modern JPEGs also store an orientation vector in the EXIF data, which tells the photo viewing app which way is up in the photo.
More than likely, your camera's hardware writes the photo in what you would consider the upside down orientation. It then sets the orientation EXIF based on the camera's tilt switch (gravity accelerometer sensor). Something you did to the photos probably erased this orientation EXIF. Or you're using a photo viewing app which ignores the orientation EXIF.
You can use this program to change the orientation EXIF in all your photos at once.
http
/savolai.net/software/JPEG-EXIF_autorotate
In the event that you need to really flip...