how did the south with fewer supplies and resores manage to stall a northern victory for four years?

One big advantage was that the South fought on home territory. It also had the strong support of most of the people. Confederate generals were also very good.