Frogs are able to make their croaking noises because they have simple vocal cords that have two slits in the bottom of the mouth. These slits open into what is called a vocal pouch. When air passes from the lungs through the vocal cords, a sound is produced. The inflating and deflating vocal pouch makes the sound louder or quieter.
That sound changes depending on the kind of frog there are as many different kinds of croaks as there are frogs! Frogs croak for the same reasons that many animals make noises: to track down and then select a mate, and to protect their territory from other male frogs.