Because each gigabytes holds 1,024 megabytes, there are 2,048 megabytes in 2 gigabytes. Even though the prefix "giga" generally refers to base-10 measurements, computers instead use base-2 measurements.
Because computers operate on ones and zeros instead of the numbers zero through nine, it is more useful to use units of measurement that rely on the power of two. Because of this, the prefixes "mega" and "giga" are based on 2^20 and 2^30 bytes, respectively. However, some hardware manufacturers now use base-10 measurements, which causes a considerable amount of confusion. When it comes to stored files, however, the standard units are ubiquitous.
There are 2048 megabytes in 2 gigabytes because there are 2. 10. or 1024 megabytes in one gigabyte. This is complicated slightly by the fact that there are two possible standards.