Gravitational-wave implications for structure formation: A second-order approach