The fundamental point to understand is that those names aren't spelled the same, they're written the same. The writings and readings are essentially distinct things; neither is a representation of the other.
(As an aside, Japanese doesn't really have spelling as we think of it. It has phonetic characters, but their names map 1:1 with their pronunciation, so "spelling" a Japanese word is the same thing as just saying it.)