Years of transcribing practice is how I worked it out - I can sit and listen to a piece of music and identify chord progressions in Roman numeral terms quite easily, add in a sense of key/root notes based on 38+ years of playing guitar, bass and many more instruments and it is really as simple as "I hear it and I can write it/play it"