Hi @masta,
I’m trying to understand your problem, when you enter edit mode your scene is in x-ray mode, you turn off x-ray, then go to object mode and back to edit mode and x-ray mode is on again?
Or is it that x-ray is on in edit mode and you can’t turn it off?
To start with, in the overlays dropdown menu, under shading be sure none of the items are checked on, particularly ‘Hidden Wire’
Let me know if this solves the problem or not.