'...when I tried to inhale by turning my body sideways...'
Of course, it's impossible to see what you are doing without a video. So I'm not sure we can help much.
When you are trying to breathe, is that in full stroke? Or still drills?
In full stroke, as I prepare to breathe, I turn by body roughly 45°. Then I turn my head roughly another 45°. This allows my head to face at 90° from the bottom of the pool (more or less). When I started out learning to breathe, it was more like 100 to 110° from the bottom of the pool, and I gradually learned to reduce the angle.
If you turn your whole body sideways, it is called being 'stacked' and you will sink -- or at least I DO! But maybe you didn't mean 90° sideways.