Some cameras are simple, and they do not know which way is up when it comes to images. They cannot tag the image file with anything special as to the orientation. Other cameras are a little more complex, and they have sensors that determine when the shooter is holding it to one side or the other, or even upside down. They tag the image file for that orientation.
Now, when the image file comes over to your computer and you view it on some image editor, with some programs the orientation tag is read accurately and the image is shown accurately. If the human decides that it needs to be turned, he can do that. To a large extent, the image file is only changed on the orientation tag. Different programs do this differently though, and some do it permanently. Other programs just read the tag and show it correctly, but they do not actually make any permanent change to the file.
Then, you may send that image file to somebody else for viewing. Their viewing program may or may not read the original orientation tag correctly, even if it was permanently saved. The bottom line is that all bets are off. This gets particularly messy when the shooter shoots the image with the camera almost straight up or straight down. The orientation sensors tend not to work perfectly there.