Nonfiction is a compound word, meaning it's formed by combining two words: non and fiction.
The prefix non negates the meaning of fiction, which means "imaginary or invented." Therefore, nonfiction refers to writing that is based on real events and facts.