The cell membrane is a lot like a wall or fence surrounding a city that keeps everything that is dangerous or harmful out, but lets in and out certain materials that are vital for the cell to survive. The chemicals on the cell membrane recognize which materials should be able to push through it, much like a gate in a fence or wall.
The cell membrane is supposed to be permeated by a few different materials. If the chemical makeup of a material is not what the membrane wants to allow through, then the membrane holds strong and refuses entry. This is just like a drawbridge or gate. The gatekeeper will only let a person through the wall or fence if he recognizes the person who wants to enter.