Understanding libido is very complex.
One needs to understand the sympathetic and parasympathetic pathways just to begin to understand how both need to work in harmony to make libido function.
The fact that you state when you are in the "mood" but can't sustain an erection can point to a number of issues; some mechanical and others physiological.
For starters you need a complete and thorough blood work done including about every male hormone known to man...and of course a complete Thyroid panel as well.
That's a starting point, and it may tell you something and it may not.
Libido is so freaking complex it's not even funny.