Proper concrete-cast pillboxes would take time and resources to build, so they would be placed in important locations that could be potentially expected to become under attack in the longer term, but were not close to the present front lines. In pre-war peace time conditions they were easy to construct, but during the war time it would be more challenging. Places where seaborne invasion was feared (English coast, Malta, German-occupied France etc.) are well-known, though Germans also constructed fortified lines in the east towards the end of the war.
Properly planned defensive lines would have multiple pillboxes with overlapping fields of fire covering each other. Possibly combined with gun pits and covered foxholes, all connected by trenches to allow movement under fire from one position to another. And with barbed wire, minefields, tank traps and other obstacles to the fore.
In the field, units would not typically have the time and resources to construct cast concrete defences at the front line, so you would be more likely to see bunkers constructed with logs, sandbags, soil, rocks and other locally available materials.
As for the armaments, most such defences would not have fixed weapons (though coastal artillery and other fortress artillery could be mounted so), but would be defended by whatever arms the defending unit would bring with it. So in case of a typical infantry battalion, this would be a mixture of rifles, light and heavy machineguns, anti-tank rifles, mortars and maybe anti-tank guns. However, various militaries also organised fortress units for manning defensive lines, and these would have higher than usual amount of heavy weapons, as they were intended for manning static positions rather than engaging in mobile warfare. Captured or older weapons could also be more handy on such positions than on regular units (logistics would be easier with static positions).
As for assaulting defensive lines, a well-prepared attacker would like to gather intelligence about their presence before launching an attack, so that the presence of such defences should not come as a total surprise, and the attacking forces would have assets on call to engage them.
As for means to engage them:
1.) For seaborne landings, naval gun support would be the first choice, though scoring direct hits on small pillboxes at long range on rough sea is not exactly easy.
2.) Air support (if available) might be of limited effect, at least if strafing with MG or autocannon fire. Dive bomber scoring a direct hit could be effective, but the pillboxes might not be obvious targets from the air if properly camouflaged.
3.) Tank and assault gun support for leg infantry units was historically much more limited than it is on our gaming tables, so could not be counted on too often. That said, tanks could be quite effective against MG bunkers, though keep a watch out for minefields, anti-tank gun positions and pre-plotted artillery barrages.
4.) Direct long range heavy weapons fire by infantry guns, anti-tank guns, light AA-guns or field artillery could be effective if they can be brought into a good firing position without being easily spotted.
5.) Flamethrowers, satchel charges and plain old hand grenades could be also effective if you could manage to get close enough – easier said than done, with overlapping fields of fire, minefields, barbed wire and pre-plotted mortar barrages. But an infantry unit expecting to assault a fortified line would likely be able to stock up on suitable close assault weapons – and might be assigned pioneers to held detect and clear obstacles.
6.) Long range fire with rifles, MGs, mortars, indirect artillery support etc. would help to suppress positions (and cause occasional casualty), allowing assault parties to get close by.
7.) Bunker crews may not be intended to defend their position to the last drop of blood, but may be instructed to disengage and move to a new position in the rear if the enemy manages to get too close. This might not be immediately obvious to the attacker, who might keep on attacking the position until they can be sure that it has been taken or destroyed.