I found that as well, with all phones. It's because if you point the camera straight down at the subject, sometimes called "rostrum photography", the phone doesn't really know which way to orientate, because down, i.e. gravity, is pointing straight at the subject here. Rather than if you were shooting straight ahead, and then vertical(portrait) or horizontal(landscape) mode become obvious and can be sensed by the phone to orientate the pictures correctly.
Some camera apps might have an orientation lock feature on them, so if you're doing a lot of this vertical photography, maybe able to fix it either in landscape or portrait mode.
I sometimes take pictures of documents flat on table, camera pointing down, and any that are wrongly orientated I just rotate them with two fingers in the Photos app, and they stay correct then.