How does a battery figure out how many amps to send to an electronic circuit?
Simply put, the premise of your question is faulty in just one word. A battery does not send current, a circuit pulls it.

Now for the water analogy! (Sorry, because water analogies fall apart eventually, but this one works well enough.)

When you get a drink of water, you aren't obligated to consume the entire water supply, even though it is technically available. The same is true for a circuit, or a simple light bulb or motor. It only pulls what it can use.

But let's say you were a zombie with gaping holes! Now you can drink and drink and drink, but the water just keeps running out onto the floor. So, in a way, this would be similar to a short circuit or a device with a problem; it draws much more current than it should, and might trip a circuit breaker, blow a fuse, or (if those safeties are not in place) cause a fire or other damage.

Check out the other questions I linked in a comment earlier, they'll help you gain a bit more insight:


How does the current know how much to flow, before having seen the resistor?
Choosing power supply, how to get the voltage and current ratings?