I just got a second hand Fender Mustang I and I've been playing for a while until I got a little painful shock from the strings.

I was barefoot and there is a popping sound every time I touch the strings. Also there is the weak buzzing sound coming from the amp when no metal parts are touched. I have previously used my PC to play and no notable buzzing or shocking was present, however there was a little popping sound when guitar was touched.

What should I do? Is it the amp's grounding issues or guitar's grounding issues? I switched to another socket and wore slippers to continue playing and no further shocks were received. However the popping and buzzing stayed.

If the guitar shocked you the ground is connected to the amp. What may have happened is the chassis was floating (ie not grounded through the AC outlet) Whatever voltage it was sitting at is electrically connected to the guitar strings through the cord. When you touched the strings the voltage passed through you.
I would invest $15 in an outlet tester. You can plug it in to any 110 VAC outlet and the lights will tell you if it's properly wired and grounded.
Moving on.....