In re-reading 1240 from the CCC, it simply states “…is accompanied by the minister’s words…”. This seems to leave interpretation room as to just what is “accompanied by”. It does not specifically state simultaneous actions, or one action followed by the other. When it discusses the practice of immersion, it says that “at the invocation of each person of the Most Holy Trinity, the priest immerses the candidate…”
However, 1284 in the CCC states"In case of necessity, any person can baptize provided that he have the intentio nof doint that which the Chruch does and provided that he pous water on the candidate’s head while saying: “I baptize you in the name of the Father, and of the Son and of the Holy Spirit.”
The Code of Canon Law does not address the timing issue at all (as far as I can find anyway).
“Can. 854 Baptism is to be conferred either by immersion or by pouring; the prescripts of the conference of bishops are to be observed.”
As to your concern on the validity of the baptism, the Code of Caon Law states:
"Can. 869 §1. If there is a doubt whether a person has been baptized or whether baptism was conferred validly and the doubt remains after a serious investigation, baptism is to be conferred conditionally.
§2. Those baptized in a non-Catholic ecclesial community must not be baptized conditionally unless, after an examination of the matter and the form of the words used in the conferral of baptism and a consideration of the intention of the baptized adult and the minister of the baptism, a serious reason exists to doubt the validity of the baptism.
§3. If in the cases mentioned in §§1 and 2 the conferral or validity of the baptism remains doubtful, baptism is not to be conferred until after the doctrine of the sacrament of baptism is explained to the person to be baptized, if an adult, and the reasons of the doubtful validity of the baptism are explained to the person or, in the case of an infant, to the parents."
I believe the reference to “form of the words” in subsection 2 relate to the Trinitarian Formula, but I am not a Canon Lawyer. You may wish to call your diocesean Canon Lawyer and run this question past him. You can contact him through the Chancellor’s office most times.