As it is with many Japanese words, while the pronunciation is the same, the kanji are different. That's one of the advantages of kanji: you'll never get a word wrong, unlike in English where you always require context for words with dual meanings.
二本 - Nippon (2 long/cylindrical pieces)
日本- Nippon (Japan)