Step 1: Understand the working of a galvanic cell.
A galvanic cell (or voltaic cell) is an electrochemical cell in which a spontaneous redox reaction takes place.
The oxidation and reduction reactions occurring at the electrodes generate a flow of electrons through an external circuit.
Step 2: Identify the energy transformation.
The spontaneous chemical reaction releases chemical energy.
This chemical energy is converted into electrical energy in the form of electric current flowing through the external circuit.
Thus,
\[
\text{Chemical Energy}
\longrightarrow
\text{Electrical Energy}
\]
Step 3: Analyze the other options.
Option (1): Chemical energy to mechanical energy is not the primary function of a galvanic cell.
Option (3): Electrical energy to chemical energy occurs in an electrolytic cell, not in a galvanic cell.
Option (4): Electrical energy to thermal energy occurs in heating devices and resistive circuits, not in a galvanic cell.
Step 4: Final conclusion.
Therefore, the energy conversion involved in a galvanic cell is
\[
\boxed{\text{Chemical Energy} \rightarrow \text{Electrical Energy}}
\]
Hence, the correct option is
\[
\boxed{(2)}
\]