This is kind-of sort-of half-true.
There are 12 distinct pitches in the musical alphabet of Western music, giving us 12 notes in the chromatic scale. This is why I said "12 major and 12 minor keys, for a total of 24." If you are a "by ear" player this is easy to hear, or if you are a "visual-pattern" learner, you can see that the notes on your bass fretboard repeat themselves if you go up 12 frets.
What you are talking about is "enharmonics," which is a fancy word for "notated differently, but sounds the same." For example, F# major (6 sharps) is notated differently from Gb major (6 flats) but they sound exactly the same.
Theoretically, if you include all of the enharmonic possibilities, there are at least 72 hypothetical key signatures (36 major and 36 minor) because each of the 12 pitches of the chromatic scale (or "musical alphabet") can be notated enharmonically in at least 3 different ways. For example, the key of C major could also be written as B# major or Dbb major.
Even though there are 36 possible enharmonic major keys, we often see the number 15 in beginner music textbooks. Why? Where does that number 15 come from? Is there something magical about the enharmonic keys of C#/Db, F#/Gb, and B/Cb? Do these 3 keys (or 6 keys, depending on your point of view) have special qualities that the other 9 keys do not?
The answer is that C#/Db, F#/Gb, and B/Cb are the only key signatures
that can be written without resorting to double-flat or double-sharp symbols. For example, the key of Ab could certainly also be written enharmonically as G#, but that would require an F## (double sharp), or the key of E could be written as Fb, but that would require a Bbb (double flat). Since beginners haven't learned double flats and double sharps yet, many teachers/authors prefer the simplicity of saying "there are 15 key signatures" rather than open the can of worms "there are 12 key signatures, each of which can be written enharmonically in multiple ways, however in practice we traditionally avoid enharmonic key signatures that would require double sharps or double flats." This is an historical accident of our flawed notation system (i.e. piano black keys vs. white keys), and has no audible reality in how our ear perceives the music.
Check out "The Well-Tempered Clavier" by J.S. Bach for a great lesson in how to write music in all 24 keys.