Simple, but only buy food you are actually going to eat. That means either you have a specific plan for it or it is something you or people in your household truly enjoy. Ideally both.
If you don't really like broccoli all that much AND you don't have a specific night this week when you plan to use broccoli, then it will end up soggy and thrown out in a week. I really like broccoli, so even if I don't have a specific meal in mind I am happy to roast some as a side for any dinner or wfh lunch. I don't buy green beans because I never open the fridge, see them, and think "wow I'd love green beans right now!"
And keeping veggie scraps in a bag in the freezer to make broth (carrot shreds, onion skins, celery stalks, etc).