You don't say so specifically, but I am going to guess that you are using Emacs inside a terminal. Outside of a terminal, Emacs explicitly knows when a paste is happening (because it is initiated as a paste and Emacs explicitly requests the content of the paste from the OS or X Windows or whatever). Thus Emacs can insert the pasted text into the buffer without triggering things like
electric-pair-mode that should only activate on typed characters`
Inside a terminal things are more complicated. In principle, Emacs has only the incoming stream of characters and no idea that some of them were pasted rather than typed. However, many years ago everyone realized that this was a problem and a solution was devised. Your terminal emulator knows when you are pasting, and it can send an escape sequence before and after the pasted text. Emacs sees the escape sequence and treats all incoming data as part of a paste instead of type characters until it sees the correct escape sequence to go back to normal. This is frequently called "bracketed paste mode", although there's no specific mode in Emacs that you need to enable.
Instead, you probably need to upgrade or configure your terminal emulator so that it uses bracketed pastes. There's an outside chance that you need to upgrade Emacs; support for bracketed pastes was added in Emacs 25.
Either that or you need to describe your situation more completely.