Essentially, a casino with a license from the DGOJ is only legal in Spain. While it's free to serve the local gambling market, it's not allowed to operate internationally, though it can still be among the best online casinos globally.
Gambling operators going against this rule might find themselves on the wrong side of this state body, forcing it to act. One of the things it might do is terminate that gambling provider's license, but it may impose other sanctions.
Note that welcoming gamblers outside Spain is not the only thing a local casino can do to break the DGOJ rules. There are other ways gambling websites can breach their licensing requirements, but they vary, depending on the type of permit they applied for.
Typically, the DGOJ provides two – renewable general licenses and singular licenses. The latter is valid for between three and five years, and the former is usable for a decade.