Bismillah
Thank you for your question. The answer is all three although the believer is never in a situation that is not good for them. Sometimes afflictions are a recompense for our sins which we face in this world rather than the next. At other times we face difficulties because of the actions of others, but in these kinds of tests if we are faultless then our patience is rewarded. And at times we face tests from God in order to raise us to levels that we cannot achieve with our own actions. To understand the philosophy of trial according to our scriptural sources please see these short podcasts:
https://anchor.fm/zoheir-ali-esmail/episodes/Episode-75-51-261-263-Ordeals-part-1-of-3-eb0tbj
https://anchor.fm/zoheir-ali-esmail/episodes/Episode-76-51-264-268-Ordeals-part-2-of-3-eb29it
https://anchor.fm/zoheir-ali-esmail/episodes/Episode-77-51-269-276-Ordeals-part-3-of-3-eb3rb7
May you always be successful