How to explain this solution to the common-mode voltages?
The continuity test tells adapter and device ground already connected


Doing a continuity test does not reveal the true impedance at 50 Hz (or higher) between GNDA and GNDB. Who can say whether the output terminals of the device contains (internally) a common mode choke that is being disrupted by a differential current when you grounded GNDB. There could be resistance that is still significant that your tester regards as a "pass" for continuity.


  Why does the common-mode voltages disappear when I connect the adapter
  ground to AIGND?


That's the sensible place to ground the system - then you have no AC currents passing through the "device".


  Can I safely use this method in this type of situations? I mean tying
  the power supply GND to AIGND


Prevention is better than cure and doing this prevents those AC currents entering the "device". This would be the sensible approach.