Incognito is a Latin word that English reached by way of Italian travelers.
The Latin starting point is incognitus, "unknown." Merriam-Webster builds it from in-, "not," and cognitus, the past participle of cognoscere, "to know." So the word does not just mean "hidden." It means nobody has found out who you are.
Italian kept it as incognito, and both Etymonline and Merriam-Webster say that is where English got it. Etymonline adds that in Italian it meant "unknown," especially in the context of travel.
The dates differ by dictionary. Etymonline records the noun in the 1630s, glossed "an unknown man," and the adjective and adverb in the 1640s. Merriam-Webster has the adjective and adverb from 1635 and the noun from 1638, in the sense of one appearing or living incognito.
The meanings are consistent. Etymonline glosses the adjective as "disguised under an assumed name and character" and the adverb as "unknown, with concealed identity."
Merriam-Webster links the word to Ovid, in a story where Jupiter and Mercury visit a village incognito. Writers who cared about Latin grammar kept the feminine form incognita for a woman, and Etymonline says it persisted through the 19th century. The 18th century had a casual shortening, incog.
A related phrase is older. Terra incognita, "unknown land," is recorded from the 1610s, per Etymonline.
The root verb ties the word to many others. Merriam-Webster says the same Latin root gives recognize, cognizance and connoisseur. Etymonline traces it further to the Proto-Indo-European root gno-, "to know."
Cognizance began as a different idea. Etymonline records "conisance" in the mid-14th century for a device or mark by which someone is recognized. The "knowledge" sense came about 1400. The g was restored in English spelling in the 15th century, though the pronunciation followed only gradually, since it had always been "con-."