Bell was issued the first patent for the telephone in March
1876. Along with several other inventors, Bell had been working on
methods transmit multiple frequencies simultaneously over a wire -
which is essential to voice transmission over a wire. The idea of
doing seems to have first been suggested publicly by Innocenzo
Manzetti in 1844. In August 1854, Charles Bourseul published an
article suggesting a method for constructing a 'make-and-break'
type telephone transmitter. To quote Boursuel:
"Suppose that a man speaks near a movable disc sufficiently
flexible to lose none of the vibrations of the voice; that this
disc alternately makes and breaks the currents from a battery: you
may have at a distance another disc which will simultaneously
execute the same vibrations.
In a way this would be a sort of digital transmission with the
current either on or off and the vibrations that create the sound
being produced on the receiving end by the frequency of the on and
off signal pulling and releasing the diaphragm on the other end.
This 'make-and-break' concept was an extension of the telegraph
methods then in use.
In October of 1861, Johann Philipp Reis built and demonstrated a
device based on Bourseul's idea.
On 6 April 1875, Bell's was granted U.S. Patent 161,739
"Transmitters and Receivers for Electric Telegraphs". This used
multiple vibrating steel reeds in make-break circuits - analogous
to the Reis invention.
On 7 March 1876, Bell was granted U.S. patent 174,465
"Improvement in Telegraphy". This patent covering
...the method of, and apparatus for, transmitting vocal or other
sounds telegraphically … by causing electrical undulations, similar
in form to the vibrations of the air accompanying the said vocal or
other sound.
This method became the primary technology for telephones - so in
this respect Bell was the inventor of the telephone - although many
others contributed before and after the fact to the development of
what we now experience as the telephone. Bell was one of several
people working on the telephone technology - he was the first to
patent and demonstrate a working version of a telephone device
using "electrical undulations" rather than the make-and-break
method for transforming sound into electric signals and the
electric signals back into recognizable sound (like voice).
How inventors deliver new inventions is not usually a process
that is definable. Alexander Graham Bell did not just "come up"
with the Telephone. Having breakfast he looked at his bacon and
thought, "that's it, a telephone".
While there is usually a spark that starts the process. In this
case earlier work from Carl Friedrich Gauß and Wilhelm Eduard Weber
may have been on Bell's radar but we can't be sure but you're not
asking how did he get credit, you're asking how he 'came up' with
it. Just know that at the time there were many legal battles as a
number of futurists were rushing to patent the telephone all at the
same time.
Back to Bell, as with all inventors, he saw a need first. Most
likely he simply thought, "I want to talk to people that are far
away". While people had been saying that for thousands of years,
Bell was at a particular moment in history where electricity was
available, and thus electromagnetic devices were the trend. So he
was at the right place and time when he began looking for a way to
accomplish his goal. After he figured out how, he and Thomas Watson
(Watts) created the first commercial telephone in the late
1800's.