I think both of them share similarities with gambling in sense of relying on chance to determine an outcome but the intent behind them is different. Casting lots was seen as a way to seek divine guidance rather than personal gain. It was used to make impartial decisions like choosing a leader or resolving disputes rather than for entertainment or financial stakes.
We know that gambling involves wagering something of value with the hope of personal profit comes by risk and reward. So they may involve randomness but the purpose and motivation set them apart.