Solids have a lower energy state on the molecular level, making them less likely to move. Gases have a very high energy state, so individual molecules are constantly bouncing off each other in every imaginable direction. Gases will fill any container that holds them. Liquids are between the two, with enough energy to move but not enough to defy gravity. As such, they form to fit the walls of the container but are also constrained by gravity.
It is important to note that some solids actually do flow like liquids, albeit very slowly. Over hundreds of years, a pane of glass will become thicker at the bottom and thinner at the top, although this effect is difficult to notice without very careful inspection.