The phospholipids have heads which mix with water and tails which reject water. So the tails come together in the centre of the double layer, and the heads on the outside are surrounded by water.
The lipid bilayers stop most water-soluble (hydrophilic) molecules passing through. They also stop most ions.
In cells, proteins are put in the bilayer by enzymes. The proteins decide which molecules come in and which go out of the cell. For example, cells control salt concentrations and pH by pumping ions across their membranes using proteins called ion pumps.