The primary structure of a protein is made up of amino acids whose hydrophobic side chains indicate a transmembrane region.
This is possible because the hydrophobic side chains of the amino acids interact more favorably with the fatty acyl groups of the phospholipids of the cell membrane, which anchors the protein strongly on to the membrane, when compared with the other aqueous environments that are present on either side of the cell membrane.
Also, the extrinsic proteins do not interact with the hydrophobic part of the phospholipid layer, since they are already bound to the membrane either directly by the lipid polar head interactions or indirectly due to interactions in between the integral membrane proteins.