Older combat rifles (approx> WW2) tend to be bolt action & if there is a additional "tube" near the barrel, it would be for attaching bayonets & accessories, or on some older rifles it may be a rod.
By the time personal automatic rifles came about, the need for bayonets was not seen as so important & the fittings for them became less of an integral part of the weapon, bayonets became smaller & such obvious fitting for them disappeared.
Automatic weapons are generally gas or blowback operated. Blowback weapons drive their cycle by recoil, so no gas tubes are required - although this does appear on some rifles it is generally found on smaller automatic weapons like the MP-40 or MP5. Most modern automatic rifles are gas operated, using combustion gas from the round to power the mechanism. Exactly how obvious the gas tube is depends on a number of factors - the round in use, the length of the barely, the length of the stock....... Gas tubes can be found above or below the barrel & in some weapons, like the SLR are shrouded by the stock.
Shotguns with a magazine capacity generally have a tubular magazine below the barrel, which is operated by a pump action handle sliding on the magazine.
Franchi SPAS 12 shotgun, with 8 round magazine & pump action;
Browning Automatic Rifle, with gas tube below barrel;
M1 Garand, with below barrel gas tube;
Ruger Mini 14, with below barrel gas tube enclosed is stock;
FN FAL / SLR, with above barrel gas tube, again enclosed;
AK-47, with obvious above barrel gas tube;
M-16, with above barrel gas tube which is visible below the foresight;
A diagram of the M-16, showing the gas tube;