They are held together by attractive forces: Liquids adapt to the container it's in and its molecular bonds are more suspectable to break. When it starts to freeze, their molecules are tightly bound and maintain a particular shape, by doing this we gave this molecules energy and their attractive forces are stronger and change it material state from liquid to solid.
Hope this helps, have a blessed day! :-)