Agreed, gambling and sports are different industries. Here sports industry have the ability to move on its own. The gambling industry is much dependent over the sports industry, but for the same OP have misunderstood that gambling need to be legal when the sports is legal.
As said governments have different policies which portrays why gambling is illegal in the country. Also there were more sports/games are illegal in different countries. For example cockfights, there are countries and people yet conduct those games and gamble over it.
Sports gambling is dependent on sports, but not gambling necessarily. I mean we have casinos out there that have their own gambling games such as slots, dice, blackjack, etc., so it isn't necessarily bound to sports. So even if just, for example, a country banned sports for some dumb reason, gambling could still thrive and vice versa. The two don't need to be allowed for both of them to thrive, they're two separate industries after all. If we were to actually specify it to sports gambling though, then yea, OP has it the other way around, sports gambling was just a byproduct of sports themselves imo, without sports, there wouldn't be sports betting.