The words tray, trey sound the same but have different meanings and spellings. Why do tray, trey sound the same even though they are completely different words?
The answer is simple: tray, trey are homophones of the English language.
A shallow flat receptacle with a raised edge or rim, used for carrying, holding, or displaying articles.
A shallow flat receptacle with its contents: took the patient a dinner tray.
A card, die, or domino with three pips.
Definitions from The American Heritage® Dictionary of the English Language, 4th Edition and Wordnik.
Homophones (literally "same sound") are usually defined as words that share the same pronunciation, regardless of how they are spelled.
If they are spelled the same then they are also homographs (and homonyms); if they are spelled differently then they are also heterographs (literally "different writing").