To understand the differences you need to look at the electron configurations of each of these elements. Be, atomic number 4, has a total of 4 electrons. its configuration is 1s2 2s2. It has two valence electrons, and no electron pairs. Each of these electrons can take in forming bonds, in this case with chlorine atoms. Chemical bonds involve electrons and because all electrons have a negative charge, the two bonds between the Be and Cl will arrange themselves around the central atom (Be) so that the electrons in the bonds are as far apart as possible. Thus, the molecule is linear with the chlorines on opposite sides of the Be.
In the case of water, oxygen now has a total of 8 electrons, with a configuration is 1s2 2s2 2p4. Oxygen has two electron pairs in the outer energy level, as well as two valence electrons available for bonding. The two single electrons can form bonds with two hydrogen atoms and would like to again form a linear shape. However, the two electron pairs exert a strong repulsive force on the O-H bonds, distorting them into the bent shape of the water molecule. This shape maximizes the distance between all the electrons surrounding the central oxygen atom.
As per the VSEPR Theory, the shape of the molecule is decided by the number of bonds and the number of lone pairs present in the central atom.
The maximum repulsion is between lone pairs of electrons, and the minimum repulsion is between the bond pair of electrons.
The arrangement of bond pairs and lone pairs around the central atom is such that there is minimum repulsion.
Now, in BeCl2, Be is the central atom with 2 single bonds and zero lone pairs present on it. The maximum degrees at which the two Cl atoms can be placed far from each other around the central metal Be is 180 degrees.
Thus, BeCl2 is linear
Now, in H2O, the central atom is O, which has 2 bond pairs and 2 lone pairs.
Thus, now, to minimize repulsion, the two H atoms cannot be placed 180 degrees apart from each other because there are 2 lone pairs of electrons present which have more repulsion between them, and hence the shape of the H2O molecule is bent or V-shaped.
BeCl2 doesnot have lone pairs of electron but H2O has two lone pairs of electron so it has a V shape.