> Imagine someone buys 5 panels that can each supply 5amps. They plug them into outlets on a 40 amp circuit. They then proceed to run their toaster, microwave, vacuum, and hair dryer. They can draw 65 amps through the wires before the circuit breaker trips. (40 from mains, 25 from the panels)

Circuit breakers trip bidirectionally, so the circuit breaker itself would protect if too much current is drawn through to the mains panel.

How, precisely, would you get 65A through the wiring on this 40A circuit, if I drew 40A of consumption and had 25A of supply?

The 25A cancels out the 40A, so the upstream feed would only see 15A total. You do get 65A of total current drawn through the breaker panel, which is a concern, but the supply wiring would not see 65A. Subpanels (which, this would be a subpanel if it only had 40A capacity) are typically going to be just fine.