Why must the guns of the AC-130 be on the side forcing the plane to circle the target. Would it not be more practical to have the guns underneath the plane shooting downwards?
By putting the guns on the side, the gunner can direct a continuous stream of bullets at the intended target for as long as the pilot wishes to continue circling it. If the guns were belly-mounted, the pilot would have to make multiple passes at the target zone from different directions, with long pauses between them- long enough for the enemy soldiers to reposition themselves and escape.
The C130 is a cargo aircraft. The AC130 is the airframe converted for use as a gunship, of which there are several variants.
Guns under an aircraft are usually found on helicopters, mounted on turrets. Purpose built aircraft usually integrate guns into the wings (fighters) or fuselage (A10). WW2 bombers like the Flying Fortress worked more like the AC130, and had gunners in various places including a belly mounted turret.
The low load floor of a cargo aircraft precludes placement of guns there. Additionally, the AC130 carries multiple guns. 7.62 Minigun, 25mm Gatling gun, 40mm Bofors cannon, and 105mm howitzer have all been used. Simultaneous use requires multiple mounting points. Same side placement means they can all be used on one target.
105mm Howitzer in operation.
The original concept of the AC-130 gunship was to loiter over an area for an extended period of time in support of ground troops. It provides close air support when precision is needed instead of indiscriminate strafing runs of fast movers like F-4s and other jets. Using a ground reference maneuver called turns on pylons and pivotal altitude keeps one side of the gunship perpetually aligned with a target on the ground as the aircraft circles it.
You can find more detail on the Smithsonian Channel show Air Warriors.
Because the AC-130 is an airplane, not a helicopter, the only way to "hover" over a target is to fly in a circle around the target. This is called "loitering". This is the primary use-case for the AC-130: it's basically a flying artillery position, not a flying tank.
Having guns point downwards will have the guns point away from the target (due to banking) when loitering. Making it unsuitable to be used as a flying artillery position and forcing it to behave like a bomber (flying, reusable "bullet/shell"*).
I think you've got this the wrong way round - you don't fly in circles because the guns are on the side; the guns are on the side because you have to fly in circles.
The only way to get a fixed-wing aircraft to loiter over a particular spot is for it to fly in a circle. To do this you have to bank the aircraft (i.e., tilt it on its side). If you do this, you automatically present the side of the aircraft to the target, so it's the natural place to position your guns. If you put them on the belly, you'd have to then aim them to the side - as far as they would go.
This side-firing strategy grew out of a technique developed by the British Chindits in Burma in WW2. They used small fixed-wing aircraft for supply and evacuation. The planes could not land in the jungle, so flew tight orbits over a clearing and lowered supplies on a rope. They then hauled up casualties the same way. In the Vietnam War, the Americans had the idea of replacing the rope with a line of fire and the gunship was born.