Volume too sometimes jumps to 90% when I connect my headphones to my iPhone So I recently bought an iPhone X  and have been having a ton of trouble with my Sony WH-1000XM2 that I had.

Sometimes when I connect it and play music I suddenly realize the volume is set to 90% I usually set it to 20-10% but the the next time (not always) it's set to 90% again!

The keyboard is also too loud. It's tied to my Ringer and doesn't turn down when I connect my headphones meaning I have to mute it every time after I get scared by the keyboard sound and remember to unmute it afterwards!
iPhones remember the volume settings for different sound outputs. ie. if you have the iPhone speakers, and a set of plugged in headphones, and a set of bluetooth headphones, and a wireless speaker the phone will remember the volume of each of them. When you connect the relevant device the volume is set to where you left it.

In this case you're connecting your headphones and it's setting back to where you left it.

In addition, Sony have a Headphones Connect app that can you can use to set presets for different scenarios. Do you have that app configured?