This is called pocketing food.
It usually occurs bc of undeveloped or weak jaw muscles.
My daughter had this at the same age. She was being evaluated by a speech therapist who brought this to my attention and educated us. She was wonderful, and to this day still holds a place in my heart :-).
She was referred to us from Early Childhood Intervention (EI), and we had to wait for her bc this jaw issue is a type of specialty.
Prior to her working with us I had the same issues with my daughter.
Please don't punish her anymore until this has been evaluated. It could be something or could be nothing, but let someone trained tell you. I would start to keep a record of the good she struggles with.
FWIW, I had the same struggle as a child. When my mother served meat or tougher foods they would make me sit at the table for hours until I finished. I rarely did. The reality is I couldn't, but there was no awareness then.
As an adult I still cannot eat certain foods or they trigger migraines. I have TMJ. I cannot chew gum, taffy apples or those thick pretzels without suffering from a headache or even sometimes a migraine. If mine would've been caught I might not have those problems.
Please see a pediatric speech therapist for a consultation.
Our situation is so much better. When I serve food she struggles with we have a safe, simple, healthy option that she can 'pick' so she feels like she has some control but we decide the parameters.
ETA : She may be struggling with 'mashed' or soft food if her jaw muscles are tired from eating other foods earlier in the day.
ETA2: she does not pocket anymore, she is more comfortable with new foods, and she identifies when a food is too tough for her so we cut it up more.
Kids also 'forget' about the pocketed food because the nerves in the cheek are not as developed.