Basically carbs and fat give you energy, if we’re talking the literal term. I think protein does too but it’s less.
But stimulants do unlock mental resources. I believe caffeine induces a fight or flight state (what I’ve heard; haven’t studied this), one aspect of which is the body decides to make
more energy available at the cost of faster breakdown.
Dopaminergic stimulants give your body the sense it’s pursuing something important. So the same zap of released resources called “motivation” that you’d get if you suddenly realized your favorite person in the world is outside, you can also get by taking adderall or cocaine.
Only if you take it once though. If you drink coffe regularly, you only get withdrawal symptoms if you have none instead. Coffeine has no stimulating effect if taken regularly.