To say that "God is with" those who are righteous means that he helps them. This can be stated clearly in the translation. AT: "God helps those who act righteously" or "God helps those who do the right things" (See: [[rc://en/ta/man/translate/figs-explicit]])
This speaks of the protection that Yahweh provides as if he were a shelter that one might seek in a storm. AT: "Yahweh is like a shelter of protection to him" (See: [[rc://en/ta/man/translate/figs-metaphor]])