Why does it has a better CPU in terms of GHz in contrast with the CPU
You are only looking at the GHz which is clock rate of the CPU. Which equates to how fast can a CPU take input and then process it as output. So yes, your older PC, with an older CPU has a higher clock rate than newer CPUs. But newer CPUs can simply do much, much more in the context of each clock rate.
Meaning, looking at a CPU as cars that can do—let’s say—10 back & forth trips a day. Your old jalopy can do 10 trips a day but can only carry so much in it. But a more modern car would have more space—and even a larger trunk—it can carry lots more. So each car can do 10 trips a day, but one of them can do more in a trip window (i.e.: clock speed) than another.
Part of the larger problem has been the marketing focus of CPU manufacturers which has obsessively focused on GHz as opposed to any other metric. Which leads to lots of confusion since GHz is only one discreet dimension of a larger process in terms of system speed.