You are essentially correct, in that a song or melody played in a certain key can be transposed to any other any other key - that is, can be played starting on any note and still be recognizable - but here's the nub. When we talk about the key of a piece - for example, A major - we are talking about a collection of 7 notes (In this case, A,B,C#,D,E,F#,G#, or Do, re, mi, fa, sol, la, ti). If you start in a different key - say, C Major - you would have a scale made of different tones (C,D,E,F,G,A,B); HOWEVER, they still occupy the same place in the key (Do, re, mi, etc.), and so it's easy (when you know your scales!) to transpose keys on the fly.
But in the western musical tradition, tempered instruments have 12 distinct tones! A major scale, like many common used scales, is merely a collection of tones. Most scales - for example, the major and minor scales - use 7 distinct notes just like the major scale. And while you might start a scale on the same note - in this case, A - the specific pattern of notes you pick determines the key. A major, as we have seen, is comprised of a whole step, another whole step, a half step, three whole steps, and a half step (the last half step is between G#, or ti, and A at the top, or Do):
A | A# | B | C | C# | D | D# | E | F | F# | G | G# | A
Do..........re..........mi....fa...........sol.........la.............ti....do
Alternatively, a minor scale has the pattern, whole, half, whole, whole, half, whole, whole:
A | A# | B | C | C# | D | D# | E | F | F# | G | G# | A
Do.........re....me..........fa..........sol....le...........te............do
Either of these scales can be transposed to different keys, and although the specific collection will change, the pattern of steps, and therefore the solfege (do, re, mi etc.) will not change. These patterns are called modes; the most common are major and minor. Although a scale or melody may start on the same note, it is not necessarily in the same key. Thus, the key is determined by two factors: the starting note (1st and 8th, or Do), which we call the tonic, and the mode, which have different names.
So what are the different modes? First think of a C major scale - no sharps or flats, all the white keys on a piano - C,D,E,F,G,A,B,(C). If we play the notes in this order starting on C it sounds like C major - we call this the Ionian, or major, mode. But what if we played the same collection of notes, but starting on a different note - like A for example? We get the Aeolian, or minor, scale. Starting on different notes will yield more exotic scales. (https://en.wikibooks.org/wiki/Music_Theory/Modes)
If you're interested in understand more about the nature of the scales, and music theory in general, i recommend studying the Circle of Fifths (for reading keys/music) as well as learning solfege, which helps immensely with audiating, the process of accurately expressing what you hear in your head. Once you can hear it, you can sing it, and if you can sing it, you can play it, and if you can play it, you can retire to a cottage in Florida at the age of sixty three for some quality time with the local beach bunnies.