Everything that happens in this world, and whatever actions creatures do - whether good or evil - everything happens according to the Divine Knowledge of Allah ﷻ, which He Knows in pre-eternity. Allah ﷻ & Knows everything that will come to pass and He has written down everything.
Questions V: Destiny
Is a human compelled to act according to what is written in destiny?
Answer: No. Allah ﷻ has given the choice [free-will] to humans to choose between good and evil. Whatever a man will choose to do, is written (33) with Allah ﷻ.
(33) Meaning 'Person A will do such a thing' or 'Person B will not do such a thing. This is not 'written' as in 'compelled to do but only a description of the event that the person will do such a thing.