why does wheat bread get harder as time passes by while cookies get softer?
Cookies are denser and contain more sugar than wheat bread does. Sugar is hydroscopic and so it draws water out of the air and holds it in the sugar structure. So the denser the cookie is and the more sugar it contains, the more likely it is to go soggy.
Bread has little or no sugar and so it is not hydroscopic. Its moisture evaporates into the air. The reason why bread becomes hard in a few days is because the starch molecules move together in a tighter, more ordered arrangement when the moisture which separates them is removed.