Spelling is a nightmare for most learners and users of English! It is extremely inconsistent with words and phonemes written the same way but pronounced differently and words written differently but pronounced the same.
Perhaps the most well-known example of the same letters being pronounced differently is -ough. Bough, Bought, Cough, Dough, Though, Thought, Tough, Trough, etc.
Many words that sound the same, or very similar, are written in different ways. For example, to/too, by/buy/bye,
Here is an English spelling poem that humorously depicts this situation.