I think it's considered legal because there are no regulations and institutions in the world that regulate gambling globally.
And the government of those countries cannot do anything either, because sports betting providers and online sportsbooks do not operate in their territory.
Also there is no benefit for them in taking legal action for that matter, they can't ask for taxes, etc either because for countries that consider gambling to be illegal then they can't collect taxes from gambling.