Like most actors, she read a script and liked it, and probably liked the previous work of the director. Ex Machina was good movie, and was very well received.
An actor can't know how a film is going to turn out in the end, or how it's going to do critically or financially. To suggest that she should have known and turned down the role is absurd.
And I've only heard good things about Annihilation, FWIW