I don’t understand how the Church can teach that our Lady gained in holiness at Pentecost.
Without a particular Church document to look at, I am unable to offer more than general comments:
When Mary was conceived she was created “full of grace,” in the sense that she did not lack any grace that human beings can have. But “full of grace” does not refer to a capacity limit of grace. With the grace that she had, she could build on that grace. Analogously, at baptism we receive grace, and by grace remain in a state of grace. But we can also receive more grace and grow in holiness.
At Pentecost, the Holy Spirit descended on the apostles and upon Mary in the upper room (cf. Acts 1:14, 2:1-4). It is not unreasonable to speculate that Mary, full of grace, grew in holiness at the descent of the Holy Spirit. After all, Jesus, all-perfect, in his humanity in a certain sense he grew in perfection:
In the days of his flesh, Jesus offered up prayers and supplications, with loud cries and tears, to him who was able to save him from death, and he was heard for his godly fear. Although he was a Son, he learned obedience through what he suffered; and being made perfect he became the source of eternal salvation to all who obey him (Heb. 5:7-9).