Most of the countries actually putting bans on gambling are for religious reasons and that's why it's mostly the middle east region although it's not entirely pin on those areas but I think you get the picture. Other countries are actually utilizing the massive gambling industry which is something that the government are well known for as they always exploit situation to their benefits and one way they achieve this is by taxing the gambling industry which active initiative towards this.
Agreed, some countries that have outrightly banned gambling have a religious undertone. Islam sees gambling as haram and it is forbidden for a devout Muslim to gamble. But the current crackdown on online casinos by some countries, such as the Philippines and Bangladesh, is attributed to a high rate of gambling addiction.
Sure, the government will lose revenue through taxes, licences, employment opportunities, and other social corporate responsibilities. But some of them use this ban to score cheap political points. Sure, they cannot stop gamblers from engaging, but these restrictions will reduce the number of new bettors.
Banning gambling is not right because many people engage in the activity responsibly. But just as the OP said, public enlightenment, control of advertisement, and strategies to prevent underage gambling, etc, should be used to regulate gambling activities in the country instead of an outright ban.