How is it that NASA receives broadcasts from 300 million miles away but Sprint needs to install transmitters every 500ft for 5G wireless?
Let's compare with 4G, for which I could find some numbers:
Your cell phone is transmitting with speeds of up to 50MBps with a maximum of 1 Watt (can be as low as a few µW!), using a tiny antenna that is often obscured by water bags (human flesh and organs), rocks, buildings, trees, etc.
Let's compare this with Mars Express, for example: its maximum bandwidth back to earth is "just" 230kBps (AFAIK in the same order of magnitude as EDGE) at 5 Watt (S-Band) or 65 Watt (X-Band) using a large 1.6 Meter parabolic antenna. Its signal is received by huge and very expensive antenna dishes here on earth.
So these are very different systems with very different requirements. We don't want to transmit with too much power from our cell phones, yet also want to transmit with high speeds through various obstacles. This requires receivers in closer proximity than with lower speeds and/or higher energy.
In addition to DarkDust's answer:
In radio, each two-way radio link needs its own channel, to avoid interference with other links. There is a limited number of channels available (don't know for 5G specifically, but Wifi only has 3 channels that don't interfere with each other).
So in order to support millions of simultaneous radio links, you need to reuse those channels. You can do that by reducing the range of each transmission: if a user on channel 1 only broadcasts in a 1-km radius, another user 2 km away can use channel 1 without interfering with the first user. Reduction in power also means the battery in your cell phone lasts much longer.
This is why Sprint installs so many transmitters.
For the Mars link, NASA uses a dedicated dish antenna 34 m in diameter, and a high-powered transmitter. It also supports communications with just one spacecraft at a time, so there's no need to share the radio link.