Who says the two death stars took different times to build?
First of all, the second death star wasn't even finished. They rushed just to get the main weapon built, the rest was still under construction.
Second, each movie in the original trilogy is separated by three years. The battle of Endor takes place 6 years after battle of Yavin. So they had 6 years to build it, not just a couple months. If the first death star took 20 years, maybe the second death star was only 30% complete?
Third, the first death star would have been constructed slowly, in complete secrecy. No one had any idea such a thing was being built, so it was probably not being built as fast as possible. That being said, by the time of the second one, the cat is already out of the bag, so the empire put a lot more resources into rushing that one. Not to 100%, but if they built it say twice as fast, they could get to 60%, which seems pretty close, given how it looks.