Depending on how you measure it, this isn’t necessarily true. Since the entrance to Mount Doom is on the eastern side of the mountain, Sam is technically getting closer to the Shire with every step inside the mountain.
However, the Fellowship very famously didn’t measure the trip as the eagle flies.