Well if you need a quick boner you could: start rubbing your penis and scrotum or imagine naked sexy women
it depends on your age
Touching it and thinking about something sexy usually works or better still get someone you fancy to touch it.
A bit of both
Unfortunately, penis's are not dogs and do not take commands nor can you train them. If this is an issue for you the best thing to do is to see a doctor that specializes in this. Dont know which one...