This is explained in the Bible in Ephesians 2:4-10: "It is by grace you have been saved... for it is by grace you are saved, through faith - and this not of yourselves. It is the gift of God. Not by works, so that no-one can boast. For we are God's workmanship, created in Christ Jesus to do good works, which God prepared in advance for us to do."
Notice how God's grace is mentioned twice, faith once, and works once? The grace of God has to come first, so that when a repentant sinner puts faith in that provision (Jesus' sacrificial death and resurrection being that gracious provision), then they are saved by grace alone, through faith in Christ alone. And then - because they are justified by God - they start to do the good works God had long before prepared for them to do. Those good works bring glory to God, not salvation to the person doing the good works. That's because good works that glorify God are not done for personal gain, but purely to glorify God, because the person doing them has been saved.
It's a question of order of events. Catholics seem to think they must do good works to contribute towards an eventual salvation, but the moment there is an ulterior motive in doing a work, there is no glory to God in it. Further, regarding order of events, God demonstrates His grace by doing for us what we could never do for ourselves, while we were still sinners. This is explained in Romans 3:20-28
"Through the law we become conscious of sin. But now a righteousness from God, apart from law, has been made known... [it] comes through faith in Jesus Christ, to all who believe. There is no difference, for all have sinned and fall short of the glory of God and are justified freely by his grace through the redemption that came by Christ Jesus. God presented him as a sacrifice of atonement, through faith in his blood... For we maintain that a man is justified by faith without the deeds of the law." That was the Apostle Paul writing.
So, the act of Grace is performed by God first (providing Christ to bear the punishment for our sins we deserve to suffer), when we see how hideous our sins are that the penalty was so severe, we are burdened by our sins, confess to God who then uplifts that burden off us, and we put total faith in Christ alone. Being in agreement with the justification of God, we can then do the good works that are fitting for saved sinners to do. It is all of God, from start to finish! That's the miracle of grace which, when grasped, leads to putting faith in what Jesus did to save us.