There's a reason why cakes, cookies, and donuts are more popular at parties than the healthier counterparts (read: icky vegetables and boring fruits). In terms of taste, the sweet-salty-umami combinations hits all the right notes in the brain. That's why we continue to indulge in these snacks, while simultaneously dubbing them "junk" food.
At its core, junk foods are high in salt, sugar, and fat. Even though we've moved beyond our hunter-gatherer past, our brains are hardwired to crave these substances. We've learned to like salty foods in order to replenish the body's sodium levels, while sugary and fatty foods represent sources of energy. Thus, foods that contain the trifecta of salt, sugar, and fat (a salted-caramel chocolate chip cookie, for example), are simply irresistible.
Of note, foods that give us salt, sugar, and fat aren't necessarily all bad - our bodies need these crucial substances for survival, after all. The problem is in the overconsumption of these foods, which overwhelms the brain and the body. Instead of taking in just enough, most of us are taking in too much of these components, resulting in increased health risks across the board.
So next time you're tempted by junk food, it's okay to give in to the cravings as long as you don't overindulge too often.