gREEn7o0answered grow question 2 years ago I can say in my experience the biggest factor is genetics.
My last grow I did nothing different, same nutes, same tent/light/conditions all that changed was genetics and the buds were like dang rocks, compared to last few strains I ran which were reasonably dense, but spongy compared to this most recent run.
Aside from that, get your environment dialed in and make sure you are hitting them with AS MUCH LIGHT as they can take. Which means getting your nutrients dialed in so when they are maxing out their growth ability they are not starving/locking out.
Also ensuring they are never thirsty or over watered.
You can increase the CO2 to help.
And finally proper drying (slowly) and curing can supposedly make them slightly more dense, makes sense, if you give the plant time to shrink and tighten up as it dries vs quickly sucking moisture out.. but I am not sure if that is accurate
I would start with those, and dial them in as best as you can, I'm sure there are some products that may slightly help, but I can tell you that with cheap ass General Hydroponics Maxi series, kool bloom, molasses, and cal mag I have had some pretty decent results, and my last run had nugs that were dense AF.