It is not always good for a person to be saved from a trouble. God looks at what is best for a person in his final end and sometimes does not save him or even actively brings on the trouble.
similarly Rabeinu Bachye writes in Duties of the Heart gate 4:
But one who trusts in God, is immune from sickness and disease except
as an atonement or to increase his reward, as written "Now youths
shall become tired and weary, and young men shall stumble" (Yeshaya
40:30), "those who hope in G-d will renew strength" (Yeshaya 40:31),
and "For the arms of the wicked shall be broken, but the Lord supports
the righteous" (Tehilim 37:17).