The nucleus consists of protons and neutrons bound together by the strong nuclear force, which is a lot stronger than the electromagnetic force. As all protons are positively charged, they repel each other and the nucleus would never be stable, if it wasn't for the strong nuclear force binding them together.