mine did this, she was a real little terror too as she would scoot round a corner and duck behind a box and hide and I would lose her!
So I got strict. I said very clearly as we went in, that she had to stay with Mummy, or sit in the seat. She could choice - walk with Mummy or sit in the trolley seat, she chose walk. Then she ran. I got her back and said, Mummy said walk or stay in the seat, that was your warning, if you do it again, you have to go in the seat. 3 minutes later she ran. I picked her up and put her straight in the seat, then carried on shopping as if nothing had happened.
Look dd tomatoes - we need tomatoes, can you reach? No, Ok Mummy will get them, right lets go and find the cucumber. Only thing was she was throwing a complete and utter wobbly the whole time, trying to get out of the seat, and I just ignored, ignored ignored. Every now and then for the benefit of the other shoppers, when she screamed OUT!!! I said very calmly, Oh dear, no I can't let you out, because you ran away from Mummy.
After 10 (very long) minutes she stopped throwing a fit and calmed down. After another few minutes I said - shall we try again, do you want to walk with Mummy or ride in the seat?
This time she walked and stayed with me.
I had to do it about 3 times in all, at increasing intervals.
It startetd when she was under 2, so totally possible.