Formation mechanism of complex organic molecules in the interstellar medium