Particles in a fluid are in motion. When more particles of a substance are crowded into one region than another, their movement produces a net spread towards the less concentrated region. This process is diffusion.
An individual particle does not know which direction is less crowded. The pattern emerges from many movements. At equilibrium, particles still move, but there is no continuing net flow from one region to the other. In cells, whether a substance can diffuse across a membrane also depends on the membrane and the substance.