"For a middle class student, it's just throwing away money."
They cost money, but that's not the same as throwing money away. It depends on what you're getting in exchange. If the gap year serves its purpose of helping you figure out what you want to do, the delta in cost is substantially less than paying a few years of tuition while you figure out the same thing.
Gap years are, unfortunately, a privilege for students who are so wealthy that doesn't matter or so poor that they're on full rides anyway. For a middle class student, it's just throwing away money.