It's because of the wheels rolling across the floor and you being the path of least resistance for the electrical charge that is building up. It's annoying and painful. I wish that stores would put drag wires on their shopping carts, but until they do, this is what I do and it works!
I took a few of those cheap metal chains, the kind that look like little balls strung together (it doesn't matter what you use as long as it's metal) and I attached it to a metal clip, which I attach to the bottom of my shopping cart so the chain hangs down and drags a little on the floor. No more shocks!!! (Just remember to take it off when you empty your cart.)