I think you are asking, whether it is necessary for Mary to be without original sin in order to conceive and bear Jesus, since God can obviously preserve Mary from original sin even though her mother Anna was not without original sin.
This is a very good question. This means that the reason for Mary to be without original sin has nothing to do with preserving Jesus from sin, since He was God and was without sin anyway. The following are a few other reasons why Mary needed to be without sin for carrying Jesus.
1. Before Mary was the mother of Jesus, she was first the spouse of the Holy Spirit, or if you may say, she was Mrs. Holy Spirit. And as the spouse of God the Third Person, necessarily she needs to be spotless and without sin. In her predestination as the spouse of the Holy Spirit, she is the archetype of what humanity was meant to be when we are eventually glorified; namely, her union with the Holy Spirit is a sign pointing to our destiny of uniting with God in heaven in eternity. Since no one can unite with God when there remains any sin in him, neither can Mary unite with the Holy Spirit if she had any sin in her. And sin, once initiated in a person, cannot have its effects removed except by death and rebirth, Mary cannot have had any stain of sin since the first instance of her existence for her to remain sinless at the time of the Annunciation. She must therefore be preserved from original sin since the time of her conception.
2. Similarly, Mary is also the archetype of the Church. Her perfect union with God and the giving birth of Jesus is a sign pointing to what the Church is and does: the Church is the spotless bride of Christ, and she exists on earth to give birth to believers. Although members of the Church are all sinners while on earth, the essence of the Church is always holy and without sin, as Jesus promised. So for Mary to be the sign of the Church, necessarily she must be completely without sin in her entire life.
3. Mary is the New Eve. Our fall to sin began with the first Eve, while without original sin, freely chose to rebel against God. Mary, the New Eve, chose for us all anew to obey God, must also start with the same footage with the first Eve before the Fall, so to defeat Satan on the same spot where we first failed. Mary therefore needs to be without original sin from birth.
The above are “reasons” to explain the fact given by God, but not the “reasons” that God has to do it this way. God does not need our reasons to do what he chooses to do. That’s why the dogma of Immaculate Conception is a mystery revealed to us by God, and then we realize through reason that it is perfectly sensible.