The Hubble Space TelescopeUV Legacy Survey of Galactic Globular Clusters – V. Constraints on formation scenarios