Yes, it’s rude to just go into someone’s fridge and cupboards and help yourself. But, if they tell you to, then assume they do want you to. If you choose something, you can ask them if it’s ok to take it, just to verify. I wouldn’t go eat something that appears to be their dinner or unopened dessert, for example. I’d ask, is this ok?
Maybe you got this idea from your own home. Was your parent very protective of the food? Were they minimally polite but secretly stingy?
Funny story; once my sister had a friend sleep over. In the morning she woke up and said she had a dream that she was eating and eating. When my mom looked in the fridge, the entire roast beef was gone!