AR 350-1 specific states:
Appendix G-9g.Physical readiness testing gives Soldiers an incentive to stay in good physical condition and allows commanders a means of assessing the physical readiness levels of their units. Accordingly, all AA and RC Soldiers must be able to pass the APFT at any time, except upon return from deployment. Following redeployment, Soldiers will be administered a record APFT no earlier than three months for AA and 6 months for RC Soldiers
Based on the information provided it appears you may have been tested prematurely.
With regard to your comment about the flag action you should have been flagged immediately after failing the APFT. However it is possible to flag an individual later due to administrative oversight.