I'm sure Mozart and Bach would have been able to write as creatively whether they were composing on a grand piano or a harpsichord or an ocarina. Creativity isn't hampered by notes available on an instrument. I can play Ode To Joy on a recorder. It uses less than 3 octaves. The less notes playable on an instrument, the more one uses other elements to be creative with.
You're only proving my point. First of all, a typical pipe organ - which was Bach's instrument of choice - covers many octaves, having pipes that range from 32' t0 1'. Mozart, who could have composed exclusively for the little clavichord, chose instead the developing fortepiano - the most dramatic percussive keyboard instrument of his time.
As I'm sure you know, the famous "Ode to Joy" melody is only one theme from Beethoven's massive Ninth Symphony, which includes full orchestra and a full choir. Yes, a melody can consist of a limited range, and a fine one will sound fine even on a $3 tin whistle. But appreciate the fact that such popular melodies are often derived from massive works.
There's no argument that a musical genius can write for a limited range. But it's even more true that musical geniuses prefer a wide range of choices, from the narrow to the wide, from the miniscule to the gigantic. But I guarantee you, if Bach and Mozart had limited their music to three-octave keyboards, we would never have heard of their names. So, can you name one famous keyboardist of any style that confined himself or herself to three octaves throughout an entire career? If your claim is true, there should be many such persons.
There's an Irish melody called "Slane" that is used for a hymn called "Lord of all Hopefulness." The melody, which covers about a 1 1/2 octave range, is in E-flat Major and requires a B-flat - the note just below the lowest C on a standard C-C three-octave keyboards. I like to arrange hymn tunes, playing them at various octaves. In this particular case, it can't be done. The three-octave keyboard can provide for only one mid-octave playing of the melody. That's just one off-the-top-of-my-head example of the issues involved in diminutive keyboards.
If you want to be confined in your composing, fine. But sometimes inspiration requires more than a little keyboard can provide. And what then? Clickity-click with octave buttons while both hands are playing? It's not an option. A five-octave keyboard will allow to you play "Ode to Joy," just as well as will a three-octave keyboard. But of course, if you want to play a rendition of the Ninth Symphony, lots of luck with the three octaves.