Chemical Formulas of Acids and Bases
I'm going to assume you are in high school, thus talking about Brønsted acids/bases.

A Brønsted acid is a compound that can donate a proton $\ce{H^+}$ whereas the base can accept a proton. For some chemicals it can be easily seen that they can donate a proton, like in the example of $\ce{HNO3}$ you give. There is obviously a proton in there so it makes sense that it is an acid. For chemicals with $\ce{O^-}$ in their structure (like the $\ce{KOH}$ in your example which dissociates into $\ce{K^+}$ and $\ce{OH^-}$) it is also clear that they can accept a proton and thus are obviously a base. 

Now the difficult part is when a molecule can do both: these are called amphiprotic substances, the most famous being water $\ce{H2O}$, but there are many more of these, think about $\ce{H2PO4^-}$, it both can accept and donate a proton. In these situations molecules can indeed be considered both a base and an acid and the way they behave depends on the other molecules they come into contact with. If the other chemical is a stronger acid, as measured by the acid dissociation constant then the current molecule will act as base and vice versa.