How to make cookies that are soft and chewy, and not crunchy or hard?

Everything that has been said here, plus one that hasn’t been explicitly mentioned - moisture. Store-bought cookies like the ones you mentioned are packed with various tools (even simple ones like more salt than you’d ever see in home-made) which enhances the ability to retain and even absorb moisture. Then they’re packed in airtight packaging, so moisture lost in transit (if any) is generally re-absorbed.

That’s one of the reasons you’ll see mentions in home-made cookies to add a slice of untoasted bread to the bag, the moisture lost by the bread will help keep the cookies moister and thus more chewy. But the corn syrup is a ‘help’ as is the high melting point fats they add. In fact, any cookie with a higher than usual fat content is going to be more chewy, so egg-rich (and/or yolk rich), high butter ratios will get the job done.