If the police arrest suspected criminals and find money that can be traced back to criminal activity, they’ll confiscate it (permanently only after a trial). “Traced back” typically need not even involve checking serial numbers. If you’ve a lot of cash, but no regular job that explains how you could have that much money or why you would keep it in cash, that’s enough to confiscate it.
If, on the other hand, they find John Doe in possession of a banknote that was paid out in a ransom or stolen from a bank, and cannot link John Doe to any crime, John Doe can keep the money (they’ll ask him whether he knows where he got it and may be able to force him to exchange it for untainted money, but that’s it)
(Counterfeit money is different. If the police finds you in possession of it they’ll confiscate it, even if they know that you’re a victim)