To combat this my bank doesn't allow me to withdraw above what is in my bank account, no matter how big the check is. Like I can see the check money in there but it usually has a note that only a certain amount is usable until the check clears.
My understanding was that the money from the bad check was actually showing up in their available balance before it officially cleared. Then they’d withdraw the money before the bank actually rejected the check.
I did this by accident once when using mobile deposit of a check and missing the decimal point while typing in the amount. I was not dumb enough to think it was free money and spend it. The bank fixed it two days later.