"The risk that a digital currency can be spent twice. Double-spending is a potential problem unique to digital currencies because digital information can be reproduced relatively easily. Physical currencies do not have this issue because they cannot be easily replicated, and the parties involved in a transaction can immediately verify the bona fides of the physical currency. With digital currency, there is a risk that the holder could make a copy of the digital token and send it to a merchant or another party while retaining the original. This was a concern initially with Bitcoin, the most popular digital currency or "cryptocurrency," since it is a decentralized currency with no central agency to verify that it is spent only once. However, Bitcoin has a mechanism based on transaction logs to verify the authenticity of each transaction and prevent double-counting."
Basically double spending is spending the same money twice.
What is the solution?
"Bitcoin manages the double spending problem by implementing a confirmation mechanism and maintaining a universal ledger (called “blockchain”), similar to the traditional cash monetary system."
Basically miners are confirming the transactions. "Both transactions go into the unconfirmed pool of transactions. But only your first transaction got confirmations and was verified by miners in the next block. Your second transaction could not get enough confirmations because the miners judged it as invalid, so it was pulled from the network."
When there is two transactions with same money, miners pull the transactions simultaneously from the pool, then whichever transaction gets the maximum number of confirmations will be included in the blockchain, and the other one will be discarded.
Sources:
https://www.investopedia.com/terms/d/doublespending.asp