To understand why heavy bombers were armed this way, one must understand a bit of pre-ww2 plane development.
Around 1935, the standard fighter was a canvas-clad wooden biplane with fixed landing gear and two slow-firing machineguns. At the same time, bombers was developing, becoming all-metal twin-engined monoplanes with retractable landing gear. Even more modern monopolane fighters were often armed with only with 2 machine-guns (such as the Bf 109B and the Pzl P.11).
At this time, it was theorised that since bombers were faster than fighters, a fighter would only get one chance at a bomber (diving from above), and defensive armament that could force the fighter to divert from its path would let the bomber continue and the fighter to fail.
Since bombers, being all metal, able to carry heavier armament (such as heavy machineguns or 20mm autocannons) and having armour protection for crews and engines (which early fighters often lacked) could, in theory, both dish out and take more punishment than fighters, the concept of the "air cruiser", a bomber only armed with defensive weapons being able to dominate the air and take on fighters developed. The Dutch tried it with the Fokker T.V, the British with the Blenheim Fighter and the US tried to protect its bomber formations over Europe with YB-40 (variant of the B-17), until the concept had proven a failure (around 1940 for the British, 1943 for the US) and P-51s were available with the range to escort the bombers all the way and back.
The idea that defensive fire would force a fighter to abandon its run on a bomber was strong for a long time, and several concepts were developed on these premises. The Bolton Paul Defiant, a British fighter with a 4 machine-gun turret behind the pilot was intended as an interceptor, where the pilot would place the plane in a dead zone, usually under the forward part of the enemy bomber, and the gunner could then shoot with impunity. All sides developed heavy fighters (Whirlwind, Beaufighter, P-38, Bf 110) or used heavily armed light/medium bombers (Mosquito, Do 17 etc) in an attempt to outgun and outarmour bombers. These proved flawed if the enemy bombers had escorts of traditional fighters, but were excellent night fighters.
Bascially, two schools developed, you either protected bombers with speed (such as with the Mosquito) or with heavy defensive armament (such as with the B-17, the G variant having no less than 13 .50 machine-guns). Nowadays, we can probably say that the massive defensive armament was a dead-end in aircraft development, but during ww2, the debate was still on-going, and the development of aircraft prestanda so quick, that it was impossible to really say for certain that experiences from 1940 could be used for designs emerging in 1942.
Fighters became faster and more heavily armed, and could make multiple runs from multiple directions, and were not forced to abandon runs by defensive fire. We know that today, but the idea persisted for a long time.
Famously, Freeman Dyson, applying early principles of operation research, found that ripping out the turrets of the Lancaster during the battle of Berlin would have made it faster and more survivable. His advice was not followed. (i.e In that context it was more effective to have no turrets at all.)
The biggest contribution the turrets made was often psychological. (Not just for the defenders alone; fighters who closed in typically had the greater number of kills, - (though Dyson could find no evidence showing a reduced loss rate for the battle of berlin)) or as a lookout position.
This discussion suggests that there was some nuance - night bombing sometimes deleted some of the turrets, but could perhaps have gone further; lookouts in the turret causing the pilot to initiate evasive tactics also had value, while hand operated guns were inaccurate and often had limited field of view, rates of fire etc (varying levels of effectiveness depending upon chin turret, waist, tail turret, armament etc). Daytime bombing in tight formation allowed for the creation of a "box" where a german fighter could be exposed to a high volume of fire from multiple bombers, and would therefore be wary of attacking. The Germans did devote time, guns and tactics to breaking up the bomber formation to counter this tactic. This can be distinguished from effectiveness of defensive guns on a single bomber.
Wiki suggests the tail turret was believed to warrant the heaviest equipment on the lancaster Nevertheless, long range fighter escorts were clearly among the most effective defense...
They were manned, though some were manned remotely (depending on the turret and type of plane). Their chief effectiveness was of a deterrent nature, preventing a lingering attack or the easiest attack runs, but they were not very successful in shooting down attacking fighters (not that this stopped the bombers from over claiming by at least an order of magnitude iirc). However, with the possible exception of the tail gun, it is more likely that the added weight and drag was detrimental to the survivability of the bomber by slowing it down, making interceptions easier and forcing the bomber to spend more time under fire (including AAA).
The Germans had enough respect for the defensive armament of the heavy bombers that they made a variant of the Fw-190, the Fw-190 A8/R8 "Sturmbock", fitted with larger guns and extra armor designed for getting in close and duking it out with a box of B-17s.