First, I'm a learner of Russian myself, so the following might not be completely correct.
You should not mistake the difference between ходить and идти for a matter of perfective versus imperfective. This is a different matter. A small number of verbs of motion (see below) have the additional complication of having a form for directional motion towards a place and a different form or even a different verb for the movement as such, frequent movement or movement to and fro.
You use the directional form (here идти) when you mention the place where the movement is intended to finish, so you say "я иду в магазин". This is a single, one-directional movement, you go to the shop, and the process of walking ends there.
If you use the non-directional form (here ходить), then you imply movement as such, several instances of movement (e.g. I go to the shop every day) or a roundtrip (there and back again). Therefore if you say "я хожу в магазин" it implies, according to context, that you usually or frequently go there, that you intend to go there and return, but it does not refer to a single walk to the shop.
This distinction is only made for a small set of verbs of motion, according to my grammar there are 14 such pairs, and not all are terribly important to know:
directional - non-directional - translation
бежать бегать run
брести бродить walk leisurely
везти возить transport (driving)
вести водить drive (car as a driver), guide
гнать гонять drive (cattle), speed
ехать ездить drive (by car, not just driver)
идти ходить walk
катить катать roll
лезть лазить climb
лететь летать fly
нести носить carry
плыть плавать swim
ползти ползать crawl
тащить таскать carry, drag (sth. heavy)
The bold letter is where the emphasis goes.
As an aside, public transport according to timetables generally uses идти - ходить and vessels on water use плыть - плавать.
Now all these verbs are imperfective. Both forms may be combined with prefixes as you usually find with perfective verbs, and in that case the directional distinction is dropped, and the formerly directional verb is used for the perfective aspect, while the formerly non-directional verb is used for the imperfective aspect. So you get уйти (perfective) and уходить (imperfective) for "to walk away".
The prefix по- is special in that it makes both imperfective forms of these verbs, the directional as well as the non-directional, perfective. A directional verb with по- implies the beginning of the movement: я побежал = I began to run. A non-directional verb with по- implies short duration: я побегал = I ran a little.