In both the case of the osmotic pressure of a dilute solution and the case of the pressure exerted by an ideal gas, the solute or gas may be described as composed of non-interacting (ideal) particles, and the mathematical expressions (equations of state) describing the two situations are very similar (in one case $p=cRT$, in the other $\pi = cRT$)$^\dagger$. However it might be less confusing if equivalent to state that in both cases the equations describe similar relationships between the work required to change the volume of the system and the accompanying change in the concentration of gas or solute. In both cases work can be done by the system through an expansion, but in one case the expansion results from pressure exerted by the gas, while in the other it results from pressure exerted by the solvent. In the case of osmotic pressure, since the chemical potential of the solvent is coupled to that of the solute (as described by the Gibbs-Duhem relation) it is possible to relate the osmotic pressure to the solute concentration (in the limit of an ideal solution as described by Henry's Law).
$^\dagger$As I commented, the equations are analogous but in my opinion, "The osmotic pressure of a dilute solution is the same as it would exert if it exists as a gas in the same volume of the solution and at same temperature." is a misstatement. The entire solution, if evaporated, would not exert the same pressure. It is more subtle than that. It is the solute that would exert an equivalent pressure if a gas.