Grace is something that we do not deserve. It is personified by Jesus.
For the law was given through Moses; grace and truth came through Jesus Christ.
The Father sent his son Jesus so that we may be saved through him. We don't deserve it but God extended Grace anyway.
For by grace you have been saved through faith; and this is not your own doing, it is the gift of God.
Here the word order is 'grace' then 'faith'. This is natural and logical. Faith needs an object of faith. Christ is the object. We have faith in Christ.
and all are justified freely by his grace through the redemption that came by Christ Jesus.
Through him we have obtained access by faith into this grace in which we stand, and we rejoice in hope of the glory of God.
Why then in Romans 5:2, the word order is 'faith' then 'grace'?
Actually, the word order is 'faith' then 'this grace'.
This grace refers to Christ. In other words, we have obtained access to the Father by faith into Christ's redemption, i.e., by faith, we believe into Christ's dying for us.
Why is grace mentioned before faith in Romans 1:5?
That's natural and logical.
but faith before grace in Romans 5:2?
Romans 5:2 reads "faith into this grace", i.e., "faith into Christ's redemption" where "this grace" is the object of "faith". The key to sorting this out is the preposition "into" which does not indicate that faith comes before grace.