Confusion about 要 and 药
要 and 药
  
  Both of these are pronounced in the same way. In latin they are spelt Yào and Yào.


99% correct.  When 要 means "to request" it is pronounced yāo.  Although, most of the time 要 is pronounced yào.


  I thought each word had four tones.


Incorrect.  There are four/five tones in Mandarin (mā mǎ má mà ma), but individual characters are pronounced using just one. Each character in modern Mandarin has a single-syllable pronunciation comprising of an "initial", a "final", and a "tone".

Indeed, there's only a small number of possible pronunciations of individual characters (listed here: left = initial; right = final [and you can apply any of the tones]), so many characters are homophones.

How do we know what someone is saying?


Most words in Chinese consist of two characters (not one), e.g., 天气 (tiānqì) = weather.  There's a lot more possible two-characters combinations.
Many words with single-character forms 菜 (cài) = "vegetable" (among other meanings) also have longer, more precise forms 蔬菜 (shūcài) = "vegetable" (no other meanings).
Whoever is speaking is aware of the potential for ambiguity, typically familiar with commonly misheard words, and phrases sentences accordingly.




Usually the most confusing one is shì:




  是 事 市 式 试 室 世 视 适 示


These are all always pronounced shì, and they all arise fairly early in one's Chinese studies.  But they're usually combined with other characters:


是 (shì) = "to be"
事情 (shìqing) = "matter"
城市 (chéngshì) = "city"
日式 (Rìshì) = "Japanese style"
尝试 (chángshì) = "to try"
办公室 (bàngōngshì) = "office"
世界 (shìjiè) = "the earth"
电视 (diànshì) = "TV"
适合 (shìhé) = "to suit"
表示 (biǎoshì) = "to express"


So we can deduce the meaning of "shì" from the word it belongs to.