The good way to think about pressing single strings (not applicable for barre though). Just think about it like driving your nail into the fingerboard. Your nail and the fingerboard should be at 90 degree angle to each other. That way you’ll make much more space for strings below.
Another way to approach this: when you look down on your left hand you should see whole the nail of a fretting finger. If you see just the fingertip then your finger is too flat.
In general you should try to maintain the arch-like (or claw-like) shape of your left hand fingers. Arch is the best way to transmit movement of your muscles into your fingertips (look at architecture).
One last thing: if your nail is too long it will hit the fingerboard before the string is pressed to the fret. Keep them short.