Uncovering the mechanism of innovation in ecosystems