Apparently, they went in circles the whone time due to them avoiding a herd. This is shown when the group is looking at the map before finding the prison. Then after 8 months, they circled back to their original location and found the prison.
You're not the only one confused with that. What happened was that Chandler Riggs had a growth spurt and they said that there was a 8 month timeskip because he looked alot older. Rick and them left that campsite and went house to house and at least one storage facility for eight months. I know it's kind of a plot hole that they didn't know that the prison was right next to them.