Crazy Rick makes crazy, illogical choices. I don't see what the problem is here.
It made sense to me, Rick and the rest of the survivors at the prison were just fine with what supplies they were able to find at the prison and the nearby area...until the Governor shows up and literally knocks down their front door. If I remember correctly, they lost some of their guns and used a good amount of ammo when they rescued Glenn and Maggie from Woodbury, plus, who knows how much ammo they wasted shooting at air when the Governor attacked the prison. Now they need to find more supplies and Rick knew
that there were supplies in his home town. Instead of devoting the time and resources to continue searching the surrounding area, Rick made a judgement call to go home.
I'm not going to spend much time concerned with the geography of the area because it's really not that hard to figure out. Rick left his town to go to Atlanta. From Atlanta, he led the group to Hershel's farm. In all the confusion of the zombie herd they wound up who knows where, with who knows how many roads closed or blocked. It's not much of a stretch to say that while fleeing the farm, the group took a route that took them back towards Rick's home town. I'm completely fine with the idea that that prison is only 1 - 3 hours away from Rick's town.