God does whatever He wills in Heaven and on earth.
Part of the reason, as you read the chapter, for the manifestation of gifts prior to Baptism is to reveal to Peter that God’s salvation is extended to the Gentiles and not simply limited to the Jews. Notice also that it is before Peter visits Cornelius that he has his dream while napping on the roof, the dream with foods considered unclean under Mosaic Law.
As 21st century Christians, we recognize that Christ paid for our salvation on Calvary. Yet even before his death on the cross, as He healed people how many times He said. “Your faith has saved you.”
Cornelius was rewarded for his righteousness. He had faith and was open to the gifts of the Holy Spirit.