Consistency of the AdS7×S4 reduction and the origin of self-duality in odd dimensions