How did the Chinese invent the computer?

They didn't. They didn't even invent the abacus (which is only a calculation aid not a computer).