A possible answer from what I've searched on the internet so far..
The strength of basicity of amines depends on two factors: 1) the availability of the lone pair for donation to a proton, 2) the stability of the conjugate acid of the amine.
In methylamine, the conjugate acid, $CH_3NH_3^+$ will attract water molecules and ion-dipole interactions will form between the cation (the conjugate acid of methylamine) and the partial negative charge on O in the water molecule. This ion-dipole interaction or attractive force helps to stabilize the positive charge on the cation.
So, the more water molecules you have solvating your cation, the more stable the conjugate base. However, the more alkyl groups you have, the less stable the conjugate base, because these alkyl groups are hindering water molecules from coming and stabilizing the conjugate base.
[The N atom is "shielded" by the bulky alkyl groups which take up a lot of space and prevent any water molecules from stabilizing the conjugate acid. Water molecules can only come in from where the H atom is where the shape of the conjugate acid is that of a pyramid. Note that there is a positive charge on N.]
As methylamine has the least number of alkyl groups as compared to dimethylamine and trimethylamine, at this point, it would be the strongest base. However, basicity also depends on the availability of the lone pair of electrons on the N atom of the amine itself. As methylamine has the least number of alkyl groups, the inductive effect by the alkyl group is the least out of methylamine, dimethylamine, and trimethylamine.
So, it really is a measure of which factor is more dominant or which factor outweighs the other. In this case, although trimethylamine has the most number of alkyl groups, the three bulky alkyl groups prevent a lot of water molecules from stabilizing the conjugate acid. And, for dimethylamine, although dimethylamine has a fewer number of alkyl groups than trimethylamine, the inductive effect of the alkyl groups outweighs the steric hindrance from the 2 alkyl groups as compared to the three in trimethylamine.
Hence, in an aqueous solution, $(CH_3)_2NH>CH_3NH_2>(CH_3)_3N>NH_3$
However, in the gaseous state, there are no water molecules to stabilize the conjugate acid and basicity depends on the inductive effect of alkyl groups; there are no water molecules to hinder. As trimethylamine is trigonal bipyramidal in shape, the factor of steric hindrance does not apply here. Hence, as trimethylamine has the most number of alkyl groups, the lone pair of electrons on trimethylamine is most available for donation.