Can game companies detect pirated games and sue if the user obtained the games using legitimate ways in other platforms?
E.g. If a user obtained a game on Xbox/PlayStation in a legitimate way by buying it with money, but the same user obtained a pirated copy of the same game on PC, can the game developer sue for any reason?
Whether a company has the technical ability to detect an infringement is not on topic for this Stack Exchange. That aspect of your question is best asked at one of the technical Stack Exchanges.
But the legal question is whether copyright infringement is excused in some way by first obtaining a non-infringing copy.
Generally: no. The copyright owner has the exclusive right to reproduce their work. When a person gets one copy of that work legitimately, that does not in general give them a licence to reproduce that work, let alone to reproduce other variants of that work (e.g. the PC version).
Some countries provide a limited user right to create a back-up copy, but that is not what your question is positing.