She was kind of locked into a single course of action after, in a drug-addled state, I might add, she saw the guards raise their guns at her again after she led them to Book, and Cosmo started to beg them to let him kill her. So she made the split-second conclusion that if she didn't get out of this place as soon as possible, she would probably never get a chance to reach Discovery any time soon even if she survived, and escaping together with Book seemed like the only way to achieve that. And Book's ship needed dilithium after she had broken his recrystallizer. What else should she have done? Stand there doing nothing and hope that the guards who seemed nothing more than the hired thugs of some warlord at this point would not shoot her and would not only let her go but even allow her to use the comms free of charge just because she asks nicely?
You’re looking at it from an in-universe perspective, while I am not. But, even in-universe, it’s not like they went there with a plan to steal a bunch of dilithium.