Niemcy and Nemetorszag both stem from old slavic “nem” (or something similar) meaning “mute”.
More precisely, the first one is from Proto-Slavic root *něm- (“mute”) and suffix *-ьcь (“person with that characteristic”); ě was not quite the same sound as e, so linguists mark it with the haček, just as it is marked in Czech to this day. In modern languages the nationality is called: Ru. nemec, Pol. Niemiec, Cro. Nijemac… But the country itself is called Ru. Germanija (from Latin), Pol. Niemcy (literally plural “Germans”), Cro. Njemačka (actually a feminine adjective, taken from the syntagm “Njemačka zemlja” = “German land”).
The Hungarian name is a combination of the Slavic loaned *němьcь > “német” (“German”) and “ország” (“land”): Németország.