Fantasy books are characterized by having magic or some other supernatural phenomena as a part of the setting.
They often include other races such as elves or dwarves.
Examples of fantasy books would be the Harry Potter series and the Lord of the Rings series.
Science fiction novels are typically characterized by a futuristic setting and advanced technology such as space travel.
Science fiction books sometimes include alien races.
Examples of science fiction books would be Ender's Game and The Foundation.
Altrenate history novels are set in our world.
However, this world differs from ours in a few key ways. A common example of this would be a story set in a world where the Nazis won World War 2.
Examples of altrenate history books would be The Man in the High Castle and The Years of Rice and Salt.
Nonfiction books do not tell a story.
They try to convey new information to the reader.
Examples of nonficton books would be Into the Wild and Outliers.