Dimers and polymers of electron deficient compounds
First of all, you have it all backwards.

You sound like the $\ce{AlCl3}$ says, "Oh, I am in solid state now! Let me turn to crystal (polymer) structure! [a while later] Oh, I am in vapour state now! Let me turn to dimer structure!"

Where in reality it says, "I don't have enough kinetic energy to break the bonds faster than they form, so I can only be in the crystal structure, in which I cannot move around, so I am in solid state now. [a while later] I have enough kinetic energy now! I can now break bonds faster than they form, but still not enough to break the bonds between the dimer, so let me exist as dimer. Also, I can move around now, since the intermolecular forces are not that strong. I am now a gas."



Almost everything polymerizes when the kinetic energy is low, forming a solid. The difference is only whether the bond responsible for the polymerization is van der Waals' forces or covalent bond or ionic bond.

For $\ce{BeH2}$, the bond is dative covalent as that makes the most sense.

For $\ce{AlCl3}$, the bond is ionic as that makes the most sense.



When the energy is high enough, $\ce{BeH2}$ decomposes, so all discussions henceforth are meaningless.

For $\ce{AlCl3}$, dimer has less energy than monomer, so dimer is formed. Remember that things like to be in states of low energy. Dimer enables it to move around, hence it is a gas.



When the energy is even higher, even the dimer bonds break and you have $\ce{AlCl3}$ monomers.