Where does the mechanical analogy come from? Why are the variables analogous to each other?
It comes from the fact that the same math describes the behavior of a mechanical system and of an electrical system. You can see that the variables (e.g. for and so on) are analogous, just by substituting them. The equation is the same, just different variable names – so the solutions for each case must show the same behavior.