liquids in general expand on heating but when water in an ordinary glass flask with a narrow neck is heated the level is found to first fall and then rise. why?

Actually that will only be true if the water starts at a temperature between 0 and 4 C. Above 4 C, it only expands as the temperature rises.

Water is a very unusual compound where thermal expansion is concerned. The reason has to do with something called hydrogen bonding between molecules.