Todd,
It appears that the first picture, that didn't turn sideways, is more of a square format. Whereas the second one, that did turn, is a regular rectangular format. When using the standard "Photo" setting on my phone I try to always hold it horizontal with the camera lens on the upper left side. I don't have issues with the pictures flipping that way. Vertical will almost always turn them sideways. And if you do horizontal with the camera lens to the lower right the pics will turn upside down on the computer. I don't use the "Square" setting enough to have a frame of reference. But it appears that you used that setting for the first pic, which may be why it didn't turn.
That's my experience, and theory anyway...