Deleting retroarch.cfg and renaming the other one didn't help. I reinstalled RetroPie with the same image. Installed plugin https://github.com/meleu/RetroPie-joystick-selection. In it I've set detect by name and set Logitech to player1 and Redragon to player2. It worked for player1 in lr-pcsx-rearmed. Not for player2. It is a problem with Redragon gamepad I think.
In plugin I've deleted 2nd gamepad and Logitech now works in all my cores and all my games and in RetroArch menu.
But when I've tried games the very first time, I had only one gamepad (Logitech) and keyboard plugged. And they didn't work in games.
I think it's the problem in RetroArch, that it decides on its own what controller to use for player. And you can't configure it easily.
That plugin is a good solution with detect by name option, it sets the corresponding device for the corresponding player as you want it, not as RetroArch wants it.
But to be sure I need to test it with normal gamepad for player2, not Redragon one.