Joh 3:5-7, 5 Jesus answered, “Most assuredly, I say to you, unless one is born of water and the Spirit, he cannot enter the kingdom of God. 6 That which is born of the flesh is flesh, and that which is born of the Spirit is spirit…
The phrase “born again” literally means “born from above of water and the Spirit”. “Born of water” is not water baptism but cleansing (regeneration). Nicodemus understood John’s baptism in response to repentance (cleansing) and believing on Him who was to come.
This understanding can be traced back to John the Baptist but even further back to the Old Testament. A better place to bring this to light is Eze 36:25-27, Paul echoes Eze 36 to Titus when he writes , “not by works of righteousness which we have done, but according to His mercy He saved us, through the washing of regeneration and renewing of the Holy Spirit” (Titus 3:5), also as seen in (Lev 15:13).
This is God’s doing, He cleanses before He indwells by the Holy Spirit. Born of water and Spirit involves cleansing of the old and a creation of the new (Rom 6:6).